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

Re: [PATCH] completion: escape metacharacters when completing paths

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 28, 2018, 23:25 UTC
Message-ID
<xmqqefa1kzcp.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20181226160835.66342-1-yousbe@gmail.com>
Chayoung You <yousbe@gmail.com> writes:
> Subject: Re: [PATCH] completion: escape metacharacters when completing paths

I am not a zsh user, but from the patch text I am getting the impression that this patch is only about zsh. If so, please help readers of "git shortlog" by saying so in the title.

	Subject: zsh: complete unquoted paths with spaces correctly
or something like that, perhaps?
Show 19 quoted lines
> Let's say there is a file named 'foo bar.txt' in repository, but it's
> not yet added to the repository. Then the following command triggers a
> completion:
>
>   git add fo<Tab>
>   git add 'fo<Tab>
>   git add "fo<Tab>
>
> The completion results in bash:
>
>   git add foo\ bar.txt
>   git add 'foo bar.txt'
>   git add "foo bar.txt"
>
> While them in zsh:
>
>   git add foo bar.txt
>   git add 'foo bar.txt'
>   git add "foo bar.txt"

You leave it unsaid what you think is wrong, and what you think should be the right output, before saying "cause of this is...".

I do not think it is given that "git add fo<TAB>" should be completed to "git add foo\ bar.txt". It would also be OK if the completion produced "git add 'foo bar.txt'", for example. So what your ideal output is is rather important, and by doing that you end up with saying what problem you have with the current output is.

So, say something here, perhaps like...
	The first one, where the pathname is not enclosed in quotes,
	should escape the SP with a backslash, just like bash
	completion does.
Previous: Chayoung YouNext: Chayoung You
Message 2 of 6 in “completion: escape metacharacters when completing paths”
  1. completion: escape metacharacters when completing pathsChayoung You, Dec 26, 2018
  2. Junio C HamanoDec 28, 2018
  3. zsh: complete unquoted paths with spaces correctlyChayoung You, Dec 30, 2018
  4. 0/2 completion: handle paths with spaces correctlyChayoung You, Jan 1, 2019
  5. 1/2 zsh: complete unquoted paths with spaces correctlyChayoung You, Jan 1, 2019
  6. 2/2 completion: treat results of git ls-tree as file pathsChayoung You, Jan 1, 2019

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.