git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "SZEDER Gábor" <szeder@ira.uka.de>
To: Jeff King <peff@peff.net>
Cc: Felipe Contreras <felipe.contreras@gmail.com>,
	git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH] Revert "completion: fix shell expansion of items"
Date: Wed, 26 Sep 2012 00:37:25 +0200	[thread overview]
Message-ID: <20120925223725.GA12658@goldbirke> (raw)
In-Reply-To: <20120925043119.GA6208@sigill.intra.peff.net>

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).


Best,
Gábor

  parent reply	other threads:[~2012-09-25 22:37 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-20  2:15 [PATCH] completion: fix shell expansion of items Felipe Contreras
2012-09-20  1:46 ` Jeff King
2012-09-20 16:52   ` Junio C Hamano
2012-09-20 18:11   ` SZEDER Gábor
2012-09-20 18:21     ` Jeff King
2012-09-20 19:38       ` Felipe Contreras
2012-09-25  4:31     ` [PATCH] Revert "completion: fix shell expansion of items" Jeff King
2012-09-25 16:03       ` Junio C Hamano
2012-09-25 22:37       ` SZEDER Gábor [this message]
2012-09-25 23:28         ` Junio C Hamano
2012-09-26 21:46         ` Jeff King
2012-09-26 21:47           ` [PATCH 1/3] t9902: add a few basic completion tests Jeff King
2012-09-26 21:51           ` [PATCH 2/3] t9902: add completion tests for "odd" filenames Jeff King
2012-09-26 21:51           ` [PATCH 3/3] completion: improve shell expansion of items Jeff King
2012-09-26 21:57             ` [PATCH 4/3] completion: quote completions we find Jeff King
2012-09-27 21:40               ` SZEDER Gábor
2012-09-27 22:31                 ` Junio C Hamano
2012-09-27 22:58                   ` SZEDER Gábor
2012-09-27  0:37             ` [PATCH 3/3] completion: improve shell expansion of items SZEDER Gábor
2012-09-27  6:28               ` Jeff King
2012-09-27  6:43                 ` Jeff King
2012-09-27 19:48                   ` Jeff King
2012-09-28 10:05                   ` SZEDER Gábor
2012-09-28 10:09                     ` [PATCH 1/5] completion: fix non-critical bugs in __gitcomp() tests SZEDER Gábor
2012-09-28 10:09                       ` [PATCH 2/5] completion: fix args of run_completion() test helper SZEDER Gábor
2012-09-28 18:04                         ` Junio C Hamano
2012-09-28 18:38                           ` SZEDER Gábor
2012-09-28 19:23                             ` Junio C Hamano
2012-09-28 19:30                               ` Jeff King
2012-09-28 19:49                                 ` Junio C Hamano
2012-09-28 19:55                                   ` Jeff King
2012-09-28 20:28                               ` SZEDER Gábor
2012-09-28 10:09                       ` [PATCH 3/5] completion: add tests for the __gitcomp_nl() completion helper function SZEDER Gábor
2012-09-28 10:09                       ` [PATCH 4/5] completion: test __gitcomp() and __gitcomp_nl() with expandable words SZEDER Gábor
2012-09-28 10:09                       ` [POC PATCH 5/5] completion: avoid compgen to fix expansion issues in __gitcomp_nl() SZEDER Gábor
2012-09-28 15:08                         ` SZEDER Gábor
2012-09-28 15:46                           ` 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=20120925223725.GA12658@goldbirke \
    --to=szeder@ira.uka.de \
    --cc=felipe.contreras@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).