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

Re: [PATCH] Revert "completion: fix shell expansion of items"

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 25, 2012, 23:28 UTC
Message-ID
<7vfw65vg17.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20120925223725.GA12658@goldbirke>
SZEDER Gábor <szeder@ira.uka.de> writes:
Show 43 quoted lines
> On Tue, Sep 25, 2012 at 12:31:19AM -0400, Jeff King wrote:
>> Yeah, doing "git checkout jk/<tab>" is not working at all, and I noticed
>> the buggy commit is on the maint track, but has not yet been released.
>> I'm not sure of the solution, but I think we should do this in the
>> meantime:
>> 
>> -- >8 --
>> Subject: Revert "completion: fix shell expansion of items"
>
> I agree with the revert, too.
>
> I looked into this issue, but quickly got lost in quoting-escaping
> hell.  Ideally we could do some quoting in __gitcomp_nl(), so it would
> work for all kinds of input, but I couldn't come up with anything
> working.  Alternatively, we could modify __gitcomp_nl()'s callers, or
> rather the helper functions supplying input to __gitcomp_nl() to do
> the quoting or escaping themselves.  Actually, that's quite easy for
> local refs, at least, because for-each-ref's builtin quoting support
> does the trick:
>
> diff --git a/contrib/completion/git-completion.bash
> b/contrib/completion/git-completion.bash
> index c48cd19f..3dc1ec8c 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -313,7 +313,7 @@ __git_refs ()
>  			refs="refs/tags refs/heads refs/remotes"
>  			;;
>  		esac
> -		git --git-dir="$dir" for-each-ref --format="%($format)" \
> +		git --git-dir="$dir" for-each-ref --shell --format="%($format)" \
>  			$refs
>  		if [ -n "$track" ]; then
>  			# employ the heuristic used by git checkout
>
> With this change completion of local refs works well, even in the
> presence of branches ${foo.bar} and foo'bar.
>
> Unfortunately, there are many callsites for __gitcomp_nl(), and it is
> invoked with refs from remote repos, heads, tags, refspecs, remotes,
> config variables, symbols from ctags, or output from stash or
> ls-tree...  although some of these are OK as they are now (remotes,
> config variables).

Whatever you do, please make the first step of that endeavour an addition to the t/t9902 to prevent the same breakage from happening again.

Thanks.
Previous: SZEDER GáborNext: Jeff King
Message 10 of 37 in “completion: fix shell expansion of items”
  1. completion: fix shell expansion of itemsFelipe Contreras, Sep 20, 2012
  2. Jeff KingSep 20, 2012
  3. Junio C HamanoSep 20, 2012
  4. SZEDER GáborSep 20, 2012
  5. Jeff KingSep 20, 2012
  6. Felipe ContrerasSep 20, 2012
  7. Revert "completion: fix shell expansion of items"Jeff King, Sep 25, 2012
  8. Junio C HamanoSep 25, 2012
  9. SZEDER GáborSep 25, 2012
  10. Junio C HamanoSep 25, 2012
  11. Jeff KingSep 26, 2012
  12. 1/3 t9902: add a few basic completion testsJeff King, Sep 26, 2012
  13. 2/3 t9902: add completion tests for "odd" filenamesJeff King, Sep 26, 2012
  14. 3/3 completion: improve shell expansion of itemsJeff King, Sep 26, 2012
  15. 4/3 completion: quote completions we findJeff King, Sep 26, 2012
  16. SZEDER GáborSep 27, 2012
  17. Junio C HamanoSep 27, 2012
  18. SZEDER GáborSep 27, 2012
  19. SZEDER GáborSep 27, 2012
  20. Jeff KingSep 27, 2012
  21. Jeff KingSep 27, 2012
  22. Jeff KingSep 27, 2012
  23. SZEDER GáborSep 28, 2012
  24. 1/5 completion: fix non-critical bugs in __gitcomp() testsSZEDER Gábor, Sep 28, 2012
  25. 2/5 completion: fix args of run_completion() test helperSZEDER Gábor, Sep 28, 2012
  26. Junio C HamanoSep 28, 2012
  27. SZEDER GáborSep 28, 2012
  28. Junio C HamanoSep 28, 2012
  29. Jeff KingSep 28, 2012
  30. Junio C HamanoSep 28, 2012
  31. Jeff KingSep 28, 2012
  32. SZEDER GáborSep 28, 2012
  33. 3/5 completion: add tests for the __gitcomp_nl() completion helper functionSZEDER Gábor, Sep 28, 2012
  34. 4/5 completion: test __gitcomp() and __gitcomp_nl() with expandable wordsSZEDER Gábor, Sep 28, 2012
  35. 5/5 completion: avoid compgen to fix expansion issues in __gitcomp_nl()SZEDER Gábor, Sep 28, 2012
  36. SZEDER GáborSep 28, 2012
  37. Jeff KingSep 28, 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.