threads / bug / 30023

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

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

## tl;dr

11 messages between Mar 22, 2012 and Mar 22, 2012.

replies: 10people: 5as markdown or json

Hong Xu· Mar 22, 2012, 06:04 UTC · lore
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· Mar 22, 2012, 10:28 UTC · re: Hong Xu · lore

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

On 03/22/2012 07:04 AM, Hong Xu wrote:
Show 9 quoted lines
> 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· Mar 22, 2012, 12:10 UTC · re: Zbigniew Jędrzejewski-Szmek · lore

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

Am 3/22/2012 11:28, schrieb Zbigniew Jędrzejewski-Szmek:
Show 20 quoted lines
> 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· Mar 22, 2012, 12:48 UTC · re: Johannes Sixt · lore

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

On Mar 22, 2012, at 20:10, Johannes Sixt <j.sixt@viscovery.net> wrote:
Show 25 quoted lines
> 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· Mar 22, 2012, 12:55 UTC · re: Hong Xu · lore

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

On 03/22/2012 01:48 PM, Hong Xu wrote:
Show 31 quoted lines
>
>
> 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· Mar 22, 2012, 13:00 UTC · re: Zbigniew Jędrzejewski-Szmek · lore

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

On 03/22/2012 08:55 PM, Zbigniew Jędrzejewski-Szmek wrote:
Show 40 quoted lines
> 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· Mar 22, 2012, 17:46 UTC · re: Zbigniew Jędrzejewski-Szmek · lore

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

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· Mar 22, 2012, 17:55 UTC · re: Junio C Hamano · lore

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

Junio C Hamano <gitster@pobox.com> writes:
Show 7 quoted lines
> 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/
Zbigniew Jędrzejewski-Szmek· Mar 22, 2012, 18:30 UTC · re: Matthieu Moy · lore

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

On 03/22/2012 06:55 PM, Matthieu Moy wrote:
Show 15 quoted lines
> 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· Mar 22, 2012, 18:45 UTC · re: Matthieu Moy · lore

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

Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:
Show 9 quoted lines
>> 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).

Hong Xu· Mar 22, 2012, 17:56 UTC · re: Junio C Hamano · lore

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

On Mar 23, 2012, at 1:46, Junio C Hamano <gitster@pobox.com> wrote:
Show 8 quoted lines
> 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

← back to recent threads