Code

completion: fast initial completion for config 'remote.*.fetch' value
authorSZEDER Gábor <szeder@ira.uka.de>
Sat, 8 Oct 2011 14:54:42 +0000 (16:54 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 21 Oct 2011 21:38:23 +0000 (14:38 -0700)
Refspecs for branches in a remote repository start with 'refs/heads/',
so completing those refspecs with 'git config remote.origin.fetch
<TAB>' always offers 'refs/heads/' first, because that's the unique
part of the possible refspecs.  But it does so only after querying the
remote with 'git ls-remote', which can take a while when the request
goes through some slower network to a remote server.

Don't waste the user's time and offer 'refs/heads/' right away for
'git config remote.origin.fetch <TAB>'.

The reason for putting 'refs/heads/' directly into COMPREPLY instead
of using __gitcomp() is to avoid __gitcomp() adding a trailing space.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/completion/git-completion.bash

index f992b1399d94fc5b20a475412efc855f27af2595..c76b645bedfbc20a12fbea8b2585216f8dd661d4 100755 (executable)
@@ -1891,6 +1891,10 @@ _git_config ()
        remote.*.fetch)
                local remote="${prev#remote.}"
                remote="${remote%.fetch}"
+               if [ -z "$cur" ]; then
+                       COMPREPLY=("refs/heads/")
+                       return
+               fi
                __gitcomp_nl "$(__git_refs_remotes "$remote")"
                return
                ;;