# [PATCH] fix global bash variable on __gitcompappend

6 messages from 2015-04-08 to 2015-04-09. Participants: Márcio Almada, Junio C Hamano, SZEDER Gábor, Marcio Almada, Eric Sunshine.
Thread: https://gitlist.dev/t/39033

## Márcio Almada, 2015-04-08 05:45

Subject: [PATCH] fix global bash variable on __gitcompappend
Message-ID: <1428471958-12339-1-git-send-email-marcio3w@gmail.com>
URL: https://gitlist.dev/e/1428471958-12339-1-git-send-email-marcio3w%40gmail.com

```
Hi,

This is how to reproduce the bug:

ˋˋˋ
git checkout [tab-tab]
echo $x # outputs the name of the last branch on completion list
ˋˋˋ

Or more directly:

ˋˋˋ
__gitcompappend "something"
echo $x # outputs 'something'
ˋˋˋ

Might not be a big deal, but it's annoying to know that `$x` is lurking.

Márcio Almada (1):
  fix global bash variable leak on __gitcompappend

 contrib/completion/git-completion.bash | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
1.9.3

```

## Márcio Almada, 2015-04-08 05:45

Subject: [PATCH] fix global bash variable leak on __gitcompappend
Message-ID: <1428471958-12339-2-git-send-email-marcio3w@gmail.com>
URL: https://gitlist.dev/e/1428471958-12339-2-git-send-email-marcio3w%40gmail.com
In-Reply-To: <1428471958-12339-1-git-send-email-marcio3w@gmail.com>

```
---
 contrib/completion/git-completion.bash | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 661a829..1620546 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -186,7 +186,7 @@ fi
 
 __gitcompappend ()
 {
-	local i=${#COMPREPLY[@]}
+	local x i=${#COMPREPLY[@]}
 	for x in $1; do
 		if [[ "$x" == "$3"* ]]; then
 			COMPREPLY[i++]="$2$x$4"
-- 
1.9.3

```

## Junio C Hamano, 2015-04-09 03:56

Subject: Re: [PATCH] fix global bash variable leak on __gitcompappend
Message-ID: <xmqqiod6ar9v.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqqiod6ar9v.fsf%40gitster.dls.corp.google.com
In-Reply-To: <1428471958-12339-2-git-send-email-marcio3w@gmail.com>

```
"Márcio Almada" <marcio.web2@gmail.com> writes:

> ---
>  contrib/completion/git-completion.bash | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Nicely found and corrected.  Please sign-off your patch and Cc area
experts if you can find them (I'll do that this time for you).

Thanks.

>
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index 661a829..1620546 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -186,7 +186,7 @@ fi
>  
>  __gitcompappend ()
>  {
> -	local i=${#COMPREPLY[@]}
> +	local x i=${#COMPREPLY[@]}
>  	for x in $1; do
>  		if [[ "$x" == "$3"* ]]; then
>  			COMPREPLY[i++]="$2$x$4"

```

## SZEDER Gábor, 2015-04-09 08:55

Subject: Re: [PATCH] fix global bash variable leak on __gitcompappend
Message-ID: <20150409105500.Horde.LF_geolXws6AivFm4yBs0w7@webmail.informatik.kit.edu>
URL: https://gitlist.dev/e/20150409105500.Horde.LF_geolXws6AivFm4yBs0w7%40webmail.informatik.kit.edu
In-Reply-To: <xmqqiod6ar9v.fsf@gitster.dls.corp.google.com>

```

Quoting Junio C Hamano <gitster@pobox.com>:

> "Márcio Almada" <marcio.web2@gmail.com> writes:
>
>> ---
>>  contrib/completion/git-completion.bash | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> Nicely found and corrected.  Please sign-off your patch and Cc area
> experts if you can find them (I'll do that this time for you).
>
> Thanks.
>
>>
>> diff --git a/contrib/completion/git-completion.bash  
>> b/contrib/completion/git-completion.bash
>> index 661a829..1620546 100644
>> --- a/contrib/completion/git-completion.bash
>> +++ b/contrib/completion/git-completion.bash
>> @@ -186,7 +186,7 @@ fi
>>
>>  __gitcompappend ()
>>  {
>> -	local i=${#COMPREPLY[@]}
>> +	local x i=${#COMPREPLY[@]}
>>  	for x in $1; do
>>  		if [[ "$x" == "$3"* ]]; then
>>  			COMPREPLY[i++]="$2$x$4"

Looks good and obviously correct, imho even at -rc2 time.

Not sure whether it's maint-worthy, but just in case: it was  
introduced in v1.8.3-rc0~59^2~2.

```

## Marcio Almada, 2015-04-09 13:52

Subject: Re: [PATCH] fix global bash variable leak on __gitcompappend
Message-ID: <CAOsHV+tCHrbmapXU+eei7v1jfiwdpK8jT+ue=kb_dm9nDXtq_Q@mail.gmail.com>
URL: https://gitlist.dev/e/CAOsHV%2BtCHrbmapXU%2Beei7v1jfiwdpK8jT%2Bue%3Dkb_dm9nDXtq_Q%40mail.gmail.com
In-Reply-To: <xmqqiod6ar9v.fsf@gitster.dls.corp.google.com>

```
2015-04-09 0:56 GMT-03:00 Junio C Hamano <gitster@pobox.com>:
> "Márcio Almada" <marcio.web2@gmail.com> writes:
>
>> ---
>>  contrib/completion/git-completion.bash | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> Nicely found and corrected.  Please sign-off your patch and Cc area
> experts if you can find them (I'll do that this time for you).
>
> Thanks.
>

Ok, I'll remember this next time. Thanks for your incredible work here.

>>
>> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
>> index 661a829..1620546 100644
>> --- a/contrib/completion/git-completion.bash
>> +++ b/contrib/completion/git-completion.bash
>> @@ -186,7 +186,7 @@ fi
>>
>>  __gitcompappend ()
>>  {
>> -     local i=${#COMPREPLY[@]}
>> +     local x i=${#COMPREPLY[@]}
>>       for x in $1; do
>>               if [[ "$x" == "$3"* ]]; then
>>                       COMPREPLY[i++]="$2$x$4"

```

## Eric Sunshine, 2015-04-09 19:26

Subject: Re: [PATCH] fix global bash variable leak on __gitcompappend
Message-ID: <CAPig+cTE+UbNaY3rewqCFjZW7nAYOTP167W3Bhp4AEZoVBt0tA@mail.gmail.com>
URL: https://gitlist.dev/e/CAPig%2BcTE%2BUbNaY3rewqCFjZW7nAYOTP167W3Bhp4AEZoVBt0tA%40mail.gmail.com
In-Reply-To: <CAOsHV+tCHrbmapXU+eei7v1jfiwdpK8jT+ue=kb_dm9nDXtq_Q@mail.gmail.com>

```
On Thu, Apr 9, 2015 at 9:52 AM, Marcio Almada <marcio.web2@gmail.com> wrote:
> 2015-04-09 0:56 GMT-03:00 Junio C Hamano <gitster@pobox.com>:
>> "Márcio Almada" <marcio.web2@gmail.com> writes:
>>>  contrib/completion/git-completion.bash | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> Nicely found and corrected.  Please sign-off your patch and Cc area
>> experts if you can find them (I'll do that this time for you).
>
> Ok, I'll remember this next time. Thanks for your incredible work here.

Junio's implication was that you should reply to his message with:

    Signed-off-by: Your Name <your@email>

Or re-send the patch with your sign-off added.

```
