[PATCH 3/3] completion: improve shell expansion of items

2012-09-26 Thread Jeff King
The current completion code doesn't deal properly with items (tags, branches, etc.) that have ${} in them because they get expanded by bash while using compgen. This patch is a rewrite of Felipe Contreras's 25ae7cf, which attempted to fix the problem by quoting the values we pass to __gitcomp_nl.

Re: [PATCH 3/3] completion: improve shell expansion of items

2012-09-26 Thread SZEDER Gábor
Hi, On Wed, Sep 26, 2012 at 05:51:19PM -0400, Jeff King wrote: > diff --git a/contrib/completion/git-completion.bash > b/contrib/completion/git-completion.bash > index be800e0..b0416ea 100644 > --- a/contrib/completion/git-completion.bash > +++ b/contrib/completion/git-completion.bash > @@ -225,6

Re: [PATCH 3/3] completion: improve shell expansion of items

2012-09-26 Thread Jeff King
On Thu, Sep 27, 2012 at 02:37:51AM +0200, SZEDER Gábor wrote: > > +# Quotes each element of an IFS-delimited list for shell reuse > > +__git_quote() > > +{ > > + local i > > + local delim > > + for i in $1; do > > + local quoted=${i//\'/\'\\\'\'} > > + printf "${delim:+$I

Re: [PATCH 3/3] completion: improve shell expansion of items

2012-09-26 Thread Jeff King
On Thu, Sep 27, 2012 at 02:28:55AM -0400, Jeff King wrote: > Thanks for reminding me to time. I noticed your a31e626 while digging in > the history, but forgot that I wanted to do a timing test. Sadly, the > results are very discouraging. Doing a similar test to your 10,000-refs, > I get: > > $

Re: [PATCH 3/3] completion: improve shell expansion of items

2012-09-27 Thread Jeff King
On Thu, Sep 27, 2012 at 02:43:38AM -0400, Jeff King wrote: > Ah. The problem is that most of the load comes from my patch 4/3, which > does a separate iteration. Here are the numbers after just patch 3: > > $ time __gitcomp_nl "$refs" > real0m0.344s > user0m0.392s > sys 0m0.04

Re: [PATCH 3/3] completion: improve shell expansion of items

2012-09-28 Thread SZEDER Gábor
On Thu, Sep 27, 2012 at 02:43:38AM -0400, Jeff King wrote: > Here are the numbers using sed[1] > instead: > -# Quotes each element of an IFS-delimited list for shell reuse > +# Quotes each element of a newline-delimited list for shell reuse > __git_quote() > { > - local i > - local deli