# [PATCH] completion: simplify __git_complete_revlist_file

6 messages from 2012-05-01 to 2012-05-07. Participants: Felipe Contreras, Junio C Hamano, SZEDER Gábor.
Thread: https://gitlist.dev/t/30383

## Felipe Contreras, 2012-05-01 18:42

Subject: [PATCH] completion: simplify __git_complete_revlist_file
Message-ID: <1335897776-3726-1-git-send-email-felipe.contreras@gmail.com>
URL: https://gitlist.dev/e/1335897776-3726-1-git-send-email-felipe.contreras%40gmail.com

```
Use new __gitcomp_nl; this is the last place that uses COMPREPLY and
compgen directly.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.bash |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 31f714d..d877a23 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -676,9 +676,7 @@ __git_complete_revlist_file ()
 		*)   pfx="$ref:$pfx" ;;
 		esac
 
-		local IFS=$'\n'
-		COMPREPLY=($(compgen -P "$pfx" \
-			-W "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \
+		__gitcomp_nl "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \
 				| sed '/^100... blob /{
 				           s,^.*	,,
 				           s,$, ,
@@ -692,7 +690,7 @@ __git_complete_revlist_file ()
 				           s,$,/,
 				       }
 				       s/^.*	//')" \
-			-- "$cur_"))
+			"$pfx" "$cur_" ""
 		;;
 	*...*)
 		pfx="${cur_%...*}..."
-- 
1.7.10

```

## Junio C Hamano, 2012-05-01 23:39

Subject: Re: [PATCH] completion: simplify __git_complete_revlist_file
Message-ID: <7vfwbj79od.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vfwbj79od.fsf%40alter.siamese.dyndns.org
In-Reply-To: <1335897776-3726-1-git-send-email-felipe.contreras@gmail.com>

```
Felipe Contreras <felipe.contreras@gmail.com> writes:

> Use new __gitcomp_nl; this is the last place that uses COMPREPLY and
> compgen directly.
>
> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
> ---
>  contrib/completion/git-completion.bash |    6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index 31f714d..d877a23 100755

This seems to be based on 'maint', which has 31f714d, but I see two hits
with "git grep 'COMPREPLY.*compgen' contrib/completion" there, so I am not
sure if that is where you wanted it to apply.

I see this was not addressed to me (neither was the other zsh one), so I
take it that the patch is still for discussion, at least for the purpose
of today's integration round.  Ping me when it is ready for either 'pu' or
'next'.

Thanks.

```

## Felipe Contreras, 2012-05-01 23:46

Subject: Re: [PATCH] completion: simplify __git_complete_revlist_file
Message-ID: <CAMP44s0z5ghcDQOeL1TrJJ7nw4=tN5MhACqcmf4EjxsNNWiQnA@mail.gmail.com>
URL: https://gitlist.dev/e/CAMP44s0z5ghcDQOeL1TrJJ7nw4%3DtN5MhACqcmf4EjxsNNWiQnA%40mail.gmail.com
In-Reply-To: <7vfwbj79od.fsf@alter.siamese.dyndns.org>

```
On Wed, May 2, 2012 at 1:39 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Felipe Contreras <felipe.contreras@gmail.com> writes:
>
>> Use new __gitcomp_nl; this is the last place that uses COMPREPLY and
>> compgen directly.
>>
>> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
>> ---
>>  contrib/completion/git-completion.bash |    6 ++----
>>  1 file changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
>> index 31f714d..d877a23 100755
>
> This seems to be based on 'maint', which has 31f714d, but I see two hits
> with "git grep 'COMPREPLY.*compgen' contrib/completion" there, so I am not
> sure if that is where you wanted it to apply.

The last place that is not the __gitcomp* functions, of course.

> I see this was not addressed to me (neither was the other zsh one), so I
> take it that the patch is still for discussion, at least for the purpose
> of today's integration round.  Ping me when it is ready for either 'pu' or
> 'next'.

I'd say at least one person should say LGTM before asking you to integrate it.

Cheers.

-- 
Felipe Contreras

```

## Felipe Contreras, 2012-05-05 15:19

Subject: Re: [PATCH] completion: simplify __git_complete_revlist_file
Message-ID: <CAMP44s3gbWCn=dB0sgDLSjfDyWFAj5zzQeHOL0exBMVP2UVgbw@mail.gmail.com>
URL: https://gitlist.dev/e/CAMP44s3gbWCn%3DdB0sgDLSjfDyWFAj5zzQeHOL0exBMVP2UVgbw%40mail.gmail.com
In-Reply-To: <CAMP44s0z5ghcDQOeL1TrJJ7nw4=tN5MhACqcmf4EjxsNNWiQnA@mail.gmail.com>

```
On Wed, May 2, 2012 at 1:46 AM, Felipe Contreras
<felipe.contreras@gmail.com> wrote:
> On Wed, May 2, 2012 at 1:39 AM, Junio C Hamano <gitster@pobox.com> wrote:

>> I see this was not addressed to me (neither was the other zsh one), so I
>> take it that the patch is still for discussion, at least for the purpose
>> of today's integration round.  Ping me when it is ready for either 'pu' or
>> 'next'.
>
> I'd say at least one person should say LGTM before asking you to integrate it.

Nobody has raised any issues with this, so, please merge it to 'pu'.
This is so straight-forward that it might make sense to move to 'next'
through.

Cheers.

-- 
Felipe Contreras

```

## SZEDER Gábor, 2012-05-05 22:40

Subject: Re: [PATCH] completion: simplify __git_complete_revlist_file
Message-ID: <20120505224014.GH2164@goldbirke>
URL: https://gitlist.dev/e/20120505224014.GH2164%40goldbirke
In-Reply-To: <CAMP44s0z5ghcDQOeL1TrJJ7nw4=tN5MhACqcmf4EjxsNNWiQnA@mail.gmail.com>

```
Hi,


On Wed, May 02, 2012 at 01:46:32AM +0200, Felipe Contreras wrote:
> On Wed, May 2, 2012 at 1:39 AM, Junio C Hamano <gitster@pobox.com> wrote:
> > Felipe Contreras <felipe.contreras@gmail.com> writes:
> >
> >> Use new __gitcomp_nl; this is the last place that uses COMPREPLY and
> >> compgen directly.

I didn't dare to touch that code back then while doing the
__gitcomp_nl() changes; that sed command looked way too scary ;) But
all it does is to process the output of 'git ls-tree' and removes the
cruft and appends a space to filenames and a '/' to directories
(without a trailing space).  So invoking __gitcomp_nl() with an empty
suffix parameter is OK, as it doesn't change the current behavior.

> >> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
> >> ---
> >>  contrib/completion/git-completion.bash |    6 ++----
> >>  1 file changed, 2 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> >> index 31f714d..d877a23 100755
> >
> > This seems to be based on 'maint', which has 31f714d, but I see two hits
> > with "git grep 'COMPREPLY.*compgen' contrib/completion" there, so I am not
> > sure if that is where you wanted it to apply.
> 
> The last place that is not the __gitcomp* functions, of course.
> 
> > I see this was not addressed to me (neither was the other zsh one), so I
> > take it that the patch is still for discussion, at least for the purpose
> > of today's integration round.  Ping me when it is ready for either 'pu' or
> > 'next'.
> 
> I'd say at least one person should say LGTM before asking you to integrate it.

Yeah, it's good to go.


Best,
Gábor

```

## Junio C Hamano, 2012-05-07 17:15

Subject: Re: [PATCH] completion: simplify __git_complete_revlist_file
Message-ID: <7vehqv7w0k.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vehqv7w0k.fsf%40alter.siamese.dyndns.org
In-Reply-To: <CAMP44s0z5ghcDQOeL1TrJJ7nw4=tN5MhACqcmf4EjxsNNWiQnA@mail.gmail.com>

```
Felipe Contreras <felipe.contreras@gmail.com> writes:

> On Wed, May 2, 2012 at 1:39 AM, Junio C Hamano <gitster@pobox.com> wrote:
> ...
>> This seems to be based on 'maint', which has 31f714d, but I see two hits
>> with "git grep 'COMPREPLY.*compgen' contrib/completion" there, so I am not
>> sure if that is where you wanted it to apply.
>
> The last place that is not the __gitcomp* functions, of course.

OK, that is what you meant by "uses ... _directly_".  With SG's Ack, will
queue.

```
