git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Hong Xu <xuhdev@gmail.com>
Date
Mar 22, 2012, 13:00 UTC
Message-ID
<4F6B2284.5030508@gmail.com>
In-Reply-To
<4F6B2146.8060408@in.waw.pl>
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
Previous: Zbigniew Jędrzejewski-SzmekNext: Junio C Hamano
Message 6 of 11 in “[BUG] git bash-completion is incorrect for "git pull origin mas<tab>" if the ssh key is encrypted”
  1. Hong XuMar 22, 2012
  2. Zbigniew Jędrzejewski-SzmekMar 22, 2012
  3. Johannes SixtMar 22, 2012
  4. Hong XuMar 22, 2012
  5. Zbigniew Jędrzejewski-SzmekMar 22, 2012
  6. Hong XuMar 22, 2012
  7. Junio C HamanoMar 22, 2012
  8. Matthieu MoyMar 22, 2012
  9. Zbigniew Jędrzejewski-SzmekMar 22, 2012
  10. Junio C HamanoMar 22, 2012
  11. Hong XuMar 22, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.