# Git completion not using ls-remote to auto-complete during push

6 messages from 2015-06-17 to 2015-06-18. Participants: Robert Dailey, Stefan Näwe, SZEDER Gábor.
Thread: https://gitlist.dev/t/39659

## Robert Dailey, 2015-06-17 16:10

Subject: Git completion not using ls-remote to auto-complete during push
Message-ID: <CAHd499Dk44Fq5c_wadxT_kuCs5BdkRwKZWOHyAgE4oi7pezxPw@mail.gmail.com>
URL: https://gitlist.dev/e/CAHd499Dk44Fq5c_wadxT_kuCs5BdkRwKZWOHyAgE4oi7pezxPw%40mail.gmail.com

```
I do the following:

$ git push origin :topic

If I stop halfway through typing 'topic' and hit TAB, auto-completion
does not work if I do not have a local branch by that name (sometimes
I delete my local branch first, then I push to delete it remotely). I
thought that git completion code was supposed to use ls-remote to auto
complete refs used in push operations. Is this supposed to work?

I'm using Git 2.4.3. Tested on both MSYS2 in Windows and Linux Mint.
Same behavior in both. I am using the latest git completion code from
the master branch in the git repo.

```

## Stefan Näwe, 2015-06-18 07:03

Subject: Re: Git completion not using ls-remote to auto-complete during push
Message-ID: <55826D2E.2060308@atlas-elektronik.com>
URL: https://gitlist.dev/e/55826D2E.2060308%40atlas-elektronik.com
In-Reply-To: <CAHd499Dk44Fq5c_wadxT_kuCs5BdkRwKZWOHyAgE4oi7pezxPw@mail.gmail.com>

```
Am 17.06.2015 um 18:10 schrieb Robert Dailey:
> I do the following:
> 
> $ git push origin :topic
> 
> If I stop halfway through typing 'topic' and hit TAB, auto-completion
> does not work if I do not have a local branch by that name (sometimes
> I delete my local branch first, then I push to delete it remotely). I
> thought that git completion code was supposed to use ls-remote to auto
> complete refs used in push operations. Is this supposed to work?
> 
> I'm using Git 2.4.3. Tested on both MSYS2 in Windows and Linux Mint.
> Same behavior in both. I am using the latest git completion code from
> the master branch in the git repo.

Same here!

But it works in my self-compiled version of msysgit (yes, the old
'Git for Windows' development environment) which is rebased onto v2.2.2.
Time for 'git bisect' I guess...

Stefan
-- 
----------------------------------------------------------------
/dev/random says: A cat sleeps fat, yet walks thin.
python -c "print '73746566616e2e6e616577654061746c61732d656c656b74726f6e696b2e636f6d'.decode('hex')" 
GPG Key fingerprint = 2DF5 E01B 09C3 7501 BCA9  9666 829B 49C5 9221 27AF

```

## SZEDER Gábor, 2015-06-18 11:29

Subject: Re: Git completion not using ls-remote to auto-complete during push
Message-ID: <1434626973-4801-1-git-send-email-szeder@ira.uka.de>
URL: https://gitlist.dev/e/1434626973-4801-1-git-send-email-szeder%40ira.uka.de
In-Reply-To: <CAHd499Dk44Fq5c_wadxT_kuCs5BdkRwKZWOHyAgE4oi7pezxPw@mail.gmail.com>

```
Quoting Robert Dailey <rcdailey.lists@gmail.com>
> I do the following:
> 
> $ git push origin :topic
> 
> If I stop halfway through typing 'topic' and hit TAB, auto-completion
> does not work if I do not have a local branch by that name (sometimes
> I delete my local branch first, then I push to delete it remotely). I
> thought that git completion code was supposed to use ls-remote to auto
> complete refs used in push operations. Is this supposed to work?

It's intentional.  Running 'git ls-remote' with a far away remote can
take ages, so instead we grab the refs on the remote from the locally
stored refs under 'refs/remotes/<remote>/'.

See e832f5c096 (completion: avoid ls-remote in certain scenarios,
2013-05-28).  The commit message mentions that you can "force"
completion of remote refs via 'git ls-remote' by starting with the full
refname, i.e.  'refs/<TAB>', however, that seems to work only on the
left hand side of the colon in the push refspec.

Gábor

```

## Robert Dailey, 2015-06-18 15:27

Subject: Re: Git completion not using ls-remote to auto-complete during push
Message-ID: <CAHd499DeUOqsuSoysaOAAYORk3B=XBXco9yEKdXt8m4XJYFyZw@mail.gmail.com>
URL: https://gitlist.dev/e/CAHd499DeUOqsuSoysaOAAYORk3B%3DXBXco9yEKdXt8m4XJYFyZw%40mail.gmail.com
In-Reply-To: <1434626973-4801-1-git-send-email-szeder@ira.uka.de>

```
On Thu, Jun 18, 2015 at 6:29 AM, SZEDER Gábor <szeder@ira.uka.de> wrote:
> Quoting Robert Dailey <rcdailey.lists@gmail.com>
>> I do the following:
>>
>> $ git push origin :topic
>>
>> If I stop halfway through typing 'topic' and hit TAB, auto-completion
>> does not work if I do not have a local branch by that name (sometimes
>> I delete my local branch first, then I push to delete it remotely). I
>> thought that git completion code was supposed to use ls-remote to auto
>> complete refs used in push operations. Is this supposed to work?
>
> It's intentional.  Running 'git ls-remote' with a far away remote can
> take ages, so instead we grab the refs on the remote from the locally
> stored refs under 'refs/remotes/<remote>/'.
>
> See e832f5c096 (completion: avoid ls-remote in certain scenarios,
> 2013-05-28).  The commit message mentions that you can "force"
> completion of remote refs via 'git ls-remote' by starting with the full
> refname, i.e.  'refs/<TAB>', however, that seems to work only on the
> left hand side of the colon in the push refspec.
>
> Gábor
>

If that's indeed the case, then completion should work. I have a
'refs/remotes/origin/topic'. Why will auto complete not work even
though this exists? Do multiple remotes cause issues (in theory there
is no reason why it should cause problems, since it should know I'm
auto-completing a ref on 'origin')?

```

## SZEDER Gábor, 2015-06-18 15:55

Subject: Re: Git completion not using ls-remote to auto-complete during push
Message-ID: <20150618175536.Horde.csrWs9ln__S_ZM2wEkboXw1@webmail.informatik.kit.edu>
URL: https://gitlist.dev/e/20150618175536.Horde.csrWs9ln__S_ZM2wEkboXw1%40webmail.informatik.kit.edu
In-Reply-To: <CAHd499DeUOqsuSoysaOAAYORk3B=XBXco9yEKdXt8m4XJYFyZw@mail.gmail.com>

```

Quoting Robert Dailey <rcdailey.lists@gmail.com>:

> On Thu, Jun 18, 2015 at 6:29 AM, SZEDER Gábor <szeder@ira.uka.de> wrote:
>> Quoting Robert Dailey <rcdailey.lists@gmail.com>
>>> I do the following:
>>>
>>> $ git push origin :topic
>>>
>>> If I stop halfway through typing 'topic' and hit TAB, auto-completion
>>> does not work if I do not have a local branch by that name (sometimes
>>> I delete my local branch first, then I push to delete it remotely). I
>>> thought that git completion code was supposed to use ls-remote to auto
>>> complete refs used in push operations. Is this supposed to work?
>>
>> It's intentional.  Running 'git ls-remote' with a far away remote can
>> take ages, so instead we grab the refs on the remote from the locally
>> stored refs under 'refs/remotes/<remote>/'.
>>
>> See e832f5c096 (completion: avoid ls-remote in certain scenarios,
>> 2013-05-28).  The commit message mentions that you can "force"
>> completion of remote refs via 'git ls-remote' by starting with the full
>> refname, i.e.  'refs/<TAB>', however, that seems to work only on the
>> left hand side of the colon in the push refspec.
>>
>> Gábor
>>
>
> If that's indeed the case, then completion should work. I have a
> 'refs/remotes/origin/topic'. Why will auto complete not work even
> though this exists? Do multiple remotes cause issues (in theory there
> is no reason why it should cause problems, since it should know I'm
> auto-completing a ref on 'origin')?

The number of remotes doesn't matter.
What matters is which side of the colon the ref to be completed is.

You can complete

   git push origin refs/<TAB>

and

   git fetch origin refs/<TAB>

will even list you refs freshly queried via 'git ls-remote'.
However,

   git push origin :refs/<TAB>
   git push origin branch:refs/<TAB>

don't work, because there are no refs starting with the prefix  
':refs/' or 'branch:refs/'.

Gábor

```

## Robert Dailey, 2015-06-18 19:12

Subject: Re: Git completion not using ls-remote to auto-complete during push
Message-ID: <CAHd499A5rUvHQBQx3GgoTGnhzOhXEwS4SFGOE=ujGo43nyTe1A@mail.gmail.com>
URL: https://gitlist.dev/e/CAHd499A5rUvHQBQx3GgoTGnhzOhXEwS4SFGOE%3DujGo43nyTe1A%40mail.gmail.com
In-Reply-To: <20150618175536.Horde.csrWs9ln__S_ZM2wEkboXw1@webmail.informatik.kit.edu>

```
On Thu, Jun 18, 2015 at 10:55 AM, SZEDER Gábor <szeder@ira.uka.de> wrote:
>
> Quoting Robert Dailey <rcdailey.lists@gmail.com>:
>
>> On Thu, Jun 18, 2015 at 6:29 AM, SZEDER Gábor <szeder@ira.uka.de> wrote:
>>>
>>> Quoting Robert Dailey <rcdailey.lists@gmail.com>
>>>>
>>>> I do the following:
>>>>
>>>> $ git push origin :topic
>>>>
>>>> If I stop halfway through typing 'topic' and hit TAB, auto-completion
>>>> does not work if I do not have a local branch by that name (sometimes
>>>> I delete my local branch first, then I push to delete it remotely). I
>>>> thought that git completion code was supposed to use ls-remote to auto
>>>> complete refs used in push operations. Is this supposed to work?
>>>
>>>
>>> It's intentional.  Running 'git ls-remote' with a far away remote can
>>> take ages, so instead we grab the refs on the remote from the locally
>>> stored refs under 'refs/remotes/<remote>/'.
>>>
>>> See e832f5c096 (completion: avoid ls-remote in certain scenarios,
>>> 2013-05-28).  The commit message mentions that you can "force"
>>> completion of remote refs via 'git ls-remote' by starting with the full
>>> refname, i.e.  'refs/<TAB>', however, that seems to work only on the
>>> left hand side of the colon in the push refspec.
>>>
>>> Gábor
>>>
>>
>> If that's indeed the case, then completion should work. I have a
>> 'refs/remotes/origin/topic'. Why will auto complete not work even
>> though this exists? Do multiple remotes cause issues (in theory there
>> is no reason why it should cause problems, since it should know I'm
>> auto-completing a ref on 'origin')?
>
>
> The number of remotes doesn't matter.
> What matters is which side of the colon the ref to be completed is.
>
> You can complete
>
>   git push origin refs/<TAB>
>
> and
>
>   git fetch origin refs/<TAB>
>
> will even list you refs freshly queried via 'git ls-remote'.
> However,
>
>   git push origin :refs/<TAB>
>   git push origin branch:refs/<TAB>
>
> don't work, because there are no refs starting with the prefix ':refs/' or
> 'branch:refs/'.
>
> Gábor
>

Interesting. So is it just a glaring bug that the git completion
script isn't ignoring the : and anything to the left of it? Or is this
beyond the control of the script?

```
