git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] fast-export: quote paths with spaces

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 26, 2012, 02:21 UTC
Message-ID
<7vk3yueru8.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1340655120-89736-1-git-send-email-jaysoffian@gmail.com>
Jay Soffian <jaysoffian@gmail.com> writes:
Show 12 quoted lines
> 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 ;-)

Show 20 quoted lines
>  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);
>  }
Previous: Jay SoffianNext: Jeff King
Message 2 of 3 in “fast-export: quote paths with spaces”
  1. fast-export: quote paths with spacesJay Soffian, Jun 25, 2012
  2. Junio C HamanoJun 26, 2012
  3. Jeff KingJun 27, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.