All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jay Soffian <jaysoffian@gmail.com>
Cc: git@vger.kernel.org, Jeff King <peff@peff.net>
Subject: Re: [PATCH] fast-export: quote paths with spaces
Date: Mon, 25 Jun 2012 19:21:03 -0700	[thread overview]
Message-ID: <7vk3yueru8.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <1340655120-89736-1-git-send-email-jaysoffian@gmail.com> (Jay Soffian's message of "Mon, 25 Jun 2012 16:12:00 -0400")

Jay Soffian <jaysoffian@gmail.com> writes:

> A path containing a space must be quoted when used as an argument to
> either the copy or rename commands. 6280dfdc3b (fast-export: quote paths
> in output, 2011-08-05) previously attempted to fix fast-export's quoting
> by passing all paths through quote_c_style(). However, that function does
> not consider the space to be a character which requires quoting, so let's
> special-case the space inside print_path(). This will cause
> space-containing paths to also be quoted in other commands where such
> quoting is not strictly necessary, but it does not hurt to do so.
>
> Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
> ---
> Sorry, not test added. I barely had time to get out this patch. :-(

Thanks.

I have to say it might be less error prone to always c-quote the
string, as the recipient is expected to be able to grok it anyway,
but I'll let fast-import/export experts to comment on it and perhaps
add a test or two ;-)

>  builtin/fast-export.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/builtin/fast-export.c b/builtin/fast-export.c
> index ef7c012094..cc5ef82fe6 100644
> --- a/builtin/fast-export.c
> +++ b/builtin/fast-export.c
> @@ -183,9 +183,11 @@ static int depth_first(const void *a_, const void *b_)
>  static void print_path(const char *path)
>  {
>  	int need_quote = quote_c_style(path, NULL, NULL, 0);
> -	if (need_quote)
> +	if (need_quote) {
>  		quote_c_style(path, NULL, stdout, 0);
> -	else
> +	} else if (strchr(path, ' ')) {
> +		printf("\"%s\"", path);
> +	} else
>  		printf("%s", path);
>  }

  reply	other threads:[~2012-06-26  2:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-25 20:12 [PATCH] fast-export: quote paths with spaces Jay Soffian
2012-06-26  2:21 ` Junio C Hamano [this message]
2012-06-27 21:58   ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vk3yueru8.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=jaysoffian@gmail.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.