# [BUG] git bash-completion is incorrect for "git pull origin mas<tab>" if the ssh key is encrypted

11 messages from 2012-03-22 to 2012-03-22. Participants: Hong Xu, Zbigniew Jędrzejewski-Szmek, Johannes Sixt, Junio C Hamano, Matthieu Moy.
Thread: https://gitlist.dev/t/30023

## Hong Xu, 2012-03-22 06:04

Subject: [BUG] git bash-completion is incorrect for "git pull origin mas<tab>" if the ssh key is encrypted
Message-ID: <4F6AC0FA.7040708@gmail.com>
URL: https://gitlist.dev/e/4F6AC0FA.7040708%40gmail.com

```
Hello everyone,

If my ssh key is encrypted, "git pull origin mas<tab>" will give a 
unexpected result, something like this:

git pull origin masEnter passphrase for key '/home/user/.ssh/id_rsa':

I know maybe it is not possible to complete the "master", but maybe it 
is better to not complete anything than append something like that?

Thanks!

Hong

```

## Zbigniew Jędrzejewski-Szmek, 2012-03-22 10:28

Subject: Re: [BUG] git bash-completion is incorrect for "git pull origin mas<tab>" if the ssh key is encrypted
Message-ID: <4F6AFEC8.9090907@in.waw.pl>
URL: https://gitlist.dev/e/4F6AFEC8.9090907%40in.waw.pl
In-Reply-To: <4F6AC0FA.7040708@gmail.com>

```
On 03/22/2012 07:04 AM, Hong Xu wrote:
> Hello everyone,
>
> If my ssh key is encrypted, "git pull origin mas<tab>" will give a
> unexpected result, something like this:
>
> git pull origin masEnter passphrase for key '/home/user/.ssh/id_rsa':
>
> I know maybe it is not possible to complete the "master", but maybe it
> is better to not complete anything than append something like that?
It is ssh itself which emits this message. The completion script calls 
'git ls-remote origin', which in turn invokes ssh. Typing the password 
in actually works, but I understand that you are annoyed by the message.

I don't think there's an easy way to silence this in git completion, 
without affecting other times when the key would be requested. E.g. we 
would want ssh to ask for the key while doing 'git pull', but not when 
run automatically during completion.

Maybe git-ls-remote should learn --quiet?

Zbyszek

```

## Johannes Sixt, 2012-03-22 12:10

Subject: Re: [BUG] git bash-completion is incorrect for "git pull origin mas<tab>" if the ssh key is encrypted
Message-ID: <4F6B16BE.1050003@viscovery.net>
URL: https://gitlist.dev/e/4F6B16BE.1050003%40viscovery.net
In-Reply-To: <4F6AFEC8.9090907@in.waw.pl>

```
Am 3/22/2012 11:28, schrieb Zbigniew Jędrzejewski-Szmek:
> On 03/22/2012 07:04 AM, Hong Xu wrote:
>> Hello everyone,
>>
>> If my ssh key is encrypted, "git pull origin mas<tab>" will give a
>> unexpected result, something like this:
>>
>> git pull origin masEnter passphrase for key '/home/user/.ssh/id_rsa':
>>
>> I know maybe it is not possible to complete the "master", but maybe it
>> is better to not complete anything than append something like that?
> It is ssh itself which emits this message. The completion script calls
> 'git ls-remote origin', which in turn invokes ssh. Typing the password in
> actually works, but I understand that you are annoyed by the message.
> 
> I don't think there's an easy way to silence this in git completion,
> without affecting other times when the key would be requested. E.g. we
> would want ssh to ask for the key while doing 'git pull', but not when run
> automatically during completion.
> 
> Maybe git-ls-remote should learn --quiet?

No. IMHO, bash completion stretches too far by asking the remote for the
refs that it has.

-- Hannes

```

## Hong Xu, 2012-03-22 12:48

Subject: Re: [BUG] git bash-completion is incorrect for "git pull origin mas<tab>" if the ssh key is encrypted
Message-ID: <03324BD2-116A-42EF-AB18-38F4A30A1115@gmail.com>
URL: https://gitlist.dev/e/03324BD2-116A-42EF-AB18-38F4A30A1115%40gmail.com
In-Reply-To: <4F6B16BE.1050003@viscovery.net>

```


On Mar 22, 2012, at 20:10, Johannes Sixt <j.sixt@viscovery.net> wrote:

> Am 3/22/2012 11:28, schrieb Zbigniew Jędrzejewski-Szmek:
>> On 03/22/2012 07:04 AM, Hong Xu wrote:
>>> Hello everyone,
>>> 
>>> If my ssh key is encrypted, "git pull origin mas<tab>" will give a
>>> unexpected result, something like this:
>>> 
>>> git pull origin masEnter passphrase for key '/home/user/.ssh/id_rsa':
>>> 
>>> I know maybe it is not possible to complete the "master", but maybe it
>>> is better to not complete anything than append something like that?
>> It is ssh itself which emits this message. The completion script calls
>> 'git ls-remote origin', which in turn invokes ssh. Typing the password in
>> actually works, but I understand that you are annoyed by the message.
>> 
>> I don't think there's an easy way to silence this in git completion,
>> without affecting other times when the key would be requested. E.g. we
>> would want ssh to ask for the key while doing 'git pull', but not when run
>> automatically during completion.
>> 
>> Maybe git-ls-remote should learn --quiet?
> 
> No. IMHO, bash completion stretches too far by asking the remote for the
> refs that it has.
> 

I agree with this rather than using silent mode. If a encrypted key is found, I think we better drop the completion. I don't know whether there is a way to implement this yet, at least we can try to find it.

Hong
```

## Zbigniew Jędrzejewski-Szmek, 2012-03-22 12:55

Subject: Re: [BUG] git bash-completion is incorrect for "git pull origin mas<tab>" if the ssh key is encrypted
Message-ID: <4F6B2146.8060408@in.waw.pl>
URL: https://gitlist.dev/e/4F6B2146.8060408%40in.waw.pl
In-Reply-To: <03324BD2-116A-42EF-AB18-38F4A30A1115@gmail.com>

```
On 03/22/2012 01:48 PM, Hong Xu wrote:
>
>
> On Mar 22, 2012, at 20:10, Johannes Sixt<j.sixt@viscovery.net>  wrote:
>
>> Am 3/22/2012 11:28, schrieb Zbigniew Jędrzejewski-Szmek:
>>> On 03/22/2012 07:04 AM, Hong Xu wrote:
>>>> Hello everyone,
>>>>
>>>> If my ssh key is encrypted, "git pull origin mas<tab>" will give a
>>>> unexpected result, something like this:
>>>>
>>>> git pull origin masEnter passphrase for key '/home/user/.ssh/id_rsa':
>>>>
>>>> I know maybe it is not possible to complete the "master", but maybe it
>>>> is better to not complete anything than append something like that?
>>> It is ssh itself which emits this message. The completion script calls
>>> 'git ls-remote origin', which in turn invokes ssh. Typing the password in
>>> actually works, but I understand that you are annoyed by the message.
>>>
>>> I don't think there's an easy way to silence this in git completion,
>>> without affecting other times when the key would be requested. E.g. we
>>> would want ssh to ask for the key while doing 'git pull', but not when run
>>> automatically during completion.
>>>
>>> Maybe git-ls-remote should learn --quiet?
>>
>> No. IMHO, bash completion stretches too far by asking the remote for the
>> refs that it has.
>>
>
> I agree with this rather than using silent mode. If a encrypted key is found, I think we better drop the completion. I don't know whether there is a way to implement this yet, at least we can try to find it.
There's more than one reason why ssh would ask for a password. So just
checking for an encrypted key is pointless. Instead, ssh could be 
invoked with -o BatchMode=yes. ls-remote could pass this option if it 
was invoked with --quiet.

Possible this is just not worth the trouble and Hong should enter the 
run ssh-agent and enter the password beforehand.

Zbyszek

```

## Hong Xu, 2012-03-22 13:00

Subject: Re: [BUG] git bash-completion is incorrect for "git pull origin mas<tab>" if the ssh key is encrypted
Message-ID: <4F6B2284.5030508@gmail.com>
URL: https://gitlist.dev/e/4F6B2284.5030508%40gmail.com
In-Reply-To: <4F6B2146.8060408@in.waw.pl>

```
On 03/22/2012 08:55 PM, Zbigniew Jędrzejewski-Szmek wrote:
> On 03/22/2012 01:48 PM, Hong Xu wrote:
>>
>>
>> On Mar 22, 2012, at 20:10, Johannes Sixt<j.sixt@viscovery.net> wrote:
>>
>>> Am 3/22/2012 11:28, schrieb Zbigniew Jędrzejewski-Szmek:
>>>> On 03/22/2012 07:04 AM, Hong Xu wrote:
>>>>> Hello everyone,
>>>>>
>>>>> If my ssh key is encrypted, "git pull origin mas<tab>" will give a
>>>>> unexpected result, something like this:
>>>>>
>>>>> git pull origin masEnter passphrase for key '/home/user/.ssh/id_rsa':
>>>>>
>>>>> I know maybe it is not possible to complete the "master", but maybe it
>>>>> is better to not complete anything than append something like that?
>>>> It is ssh itself which emits this message. The completion script calls
>>>> 'git ls-remote origin', which in turn invokes ssh. Typing the
>>>> password in
>>>> actually works, but I understand that you are annoyed by the message.
>>>>
>>>> I don't think there's an easy way to silence this in git completion,
>>>> without affecting other times when the key would be requested. E.g. we
>>>> would want ssh to ask for the key while doing 'git pull', but not
>>>> when run
>>>> automatically during completion.
>>>>
>>>> Maybe git-ls-remote should learn --quiet?
>>>
>>> No. IMHO, bash completion stretches too far by asking the remote for the
>>> refs that it has.
>>>
>>
>> I agree with this rather than using silent mode. If a encrypted key is
>> found, I think we better drop the completion. I don't know whether
>> there is a way to implement this yet, at least we can try to find it.
> There's more than one reason why ssh would ask for a password. So just
> checking for an encrypted key is pointless. Instead, ssh could be
> invoked with -o BatchMode=yes. ls-remote could pass this option if it
> was invoked with --quiet.

This is a good idea.

>
> Possible this is just not worth the trouble and Hong should enter the
> run ssh-agent and enter the password beforehand.

If I entered the password, it would be like this:

git pull origin masEnter passphrase for key '/home/user/.ssh/id_rsa':
ter

Then I press Enter, the command runs as it should be. The only problem 
is that this is a bit annoying.

Hong

```

## Junio C Hamano, 2012-03-22 17:46

Subject: Re: [BUG] git bash-completion is incorrect for "git pull origin mas<tab>" if the ssh key is encrypted
Message-ID: <7vmx78y1eq.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vmx78y1eq.fsf%40alter.siamese.dyndns.org
In-Reply-To: <4F6AFEC8.9090907@in.waw.pl>

```
Zbigniew Jędrzejewski-Szmek  <zbyszek@in.waw.pl> writes:

> Maybe git-ls-remote should learn --quiet?

I would rather think that the completion should ask for refs only when
dealing with local repositories, without going over network, whether the
query involves authentication or not.

When given a repository nickname, do we have a good way for the completion
script to tell if it is local or remote?  "type -d $it" might be cheap way
to do so, or we could even do "test $it = ." to limit it really to the
current repository.

```

## Matthieu Moy, 2012-03-22 17:55

Subject: Re: [BUG] git bash-completion is incorrect for "git pull origin mas<tab>" if the ssh key is encrypted
Message-ID: <vpqvclwo70a.fsf@bauges.imag.fr>
URL: https://gitlist.dev/e/vpqvclwo70a.fsf%40bauges.imag.fr
In-Reply-To: <7vmx78y1eq.fsf@alter.siamese.dyndns.org>

```
Junio C Hamano <gitster@pobox.com> writes:

> Zbigniew Jędrzejewski-Szmek  <zbyszek@in.waw.pl> writes:
>
>> Maybe git-ls-remote should learn --quiet?
>
> I would rather think that the completion should ask for refs only when
> dealing with local repositories, without going over network, whether the
> query involves authentication or not.

It depends on what "network" is. When the network is just a machine on
the same Gb-ethernet LAN, completion can still be useful (only if you
have password-less authentication of course). I don't use it much with
Git, but I find it handy that ZSH completes rsync remote pathes for
example.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

```

## Hong Xu, 2012-03-22 17:56

Subject: Re: [BUG] git bash-completion is incorrect for "git pull origin mas<tab>" if the ssh key is encrypted
Message-ID: <88F32C4E-F5A9-4741-8707-641F63E41E42@gmail.com>
URL: https://gitlist.dev/e/88F32C4E-F5A9-4741-8707-641F63E41E42%40gmail.com
In-Reply-To: <7vmx78y1eq.fsf@alter.siamese.dyndns.org>

```


On Mar 23, 2012, at 1:46, Junio C Hamano <gitster@pobox.com> wrote:

> Zbigniew Jędrzejewski-Szmek  <zbyszek@in.waw.pl> writes:
> 
>> Maybe git-ls-remote should learn --quiet?
> 
> I would rather think that the completion should ask for refs only when
> dealing with local repositories, without going over network, whether the
> query involves authentication or not.
> 

Could you give some reasons about why shouldn't we go through network?

Hong
```

## Zbigniew Jędrzejewski-Szmek, 2012-03-22 18:30

Subject: Re: [BUG] git bash-completion is incorrect for "git pull origin mas<tab>" if the ssh key is encrypted
Message-ID: <4F6B6FAD.6010905@in.waw.pl>
URL: https://gitlist.dev/e/4F6B6FAD.6010905%40in.waw.pl
In-Reply-To: <vpqvclwo70a.fsf@bauges.imag.fr>

```
On 03/22/2012 06:55 PM, Matthieu Moy wrote:
> Junio C Hamano<gitster@pobox.com>  writes:
>
>> Zbigniew Jędrzejewski-Szmek<zbyszek@in.waw.pl>  writes:
>>
>>> Maybe git-ls-remote should learn --quiet?
>>
>> I would rather think that the completion should ask for refs only when
>> dealing with local repositories, without going over network, whether the
>> query involves authentication or not.
>
> It depends on what "network" is. When the network is just a machine on
> the same Gb-ethernet LAN, completion can still be useful (only if you
> have password-less authentication of course). I don't use it much with
> Git, but I find it handy that ZSH completes rsync remote pathes for
> example.
Yeah, I can second that. Even on a slow network, it can be useful. I use 
ssh with ControlMaster=yes and completion over a relatively slow network 
is pretty much instantaneous.

-
Zbyszek

```

## Junio C Hamano, 2012-03-22 18:45

Subject: Re: [BUG] git bash-completion is incorrect for "git pull origin mas<tab>" if the ssh key is encrypted
Message-ID: <7vehskxymy.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vehskxymy.fsf%40alter.siamese.dyndns.org
In-Reply-To: <vpqvclwo70a.fsf@bauges.imag.fr>

```
Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:

>> I would rather think that the completion should ask for refs only when
>> dealing with local repositories, without going over network, whether the
>> query involves authentication or not.
>
> It depends on what "network" is. When the network is just a machine on
> the same Gb-ethernet LAN, completion can still be useful (only if you
> have password-less authentication of course). I don't use it much with
> Git, but I find it handy that ZSH completes rsync remote pathes for
> example.

Yeah, I agree it depends on your latency-tolerance (which implies that
this begs for an "I am impatient, do not go over network" switch).

```
