completion: fast initial completion for config 'remote.*.fetch' value

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>

SZEDER Gábor committed Oct 8, 2011 at 16:54 UTC d51a8ecd5fedb6fd09a14fc1b07f8922d6963743
1 file changed +4
contrib/completion/git-completion.bash
+4
@@ -1891,6 +1891,10 @@ _git_config ()
1891 remote.*.fetch)
1892 local remote="${prev#remote.}"
1893 remote="${remote%.fetch}"
1894 + if [ -z "$cur" ]; then
1895 + COMPREPLY=("refs/heads/")
1896 + return
1897 + fi
1898 __gitcomp_nl "$(__git_refs_remotes "$remote")"
1899 return
1900 ;;