Skip to content

Commit d51a8ec

Browse files
szedergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 48058f5 commit d51a8ec

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

contrib/completion/git-completion.bash

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1891,6 +1891,10 @@ _git_config ()
18911891
remote.*.fetch)
18921892
local remote="${prev#remote.}"
18931893
remote="${remote%.fetch}"
1894+
if [ -z "$cur" ]; then
1895+
COMPREPLY=("refs/heads/")
1896+
return
1897+
fi
18941898
__gitcomp_nl "$(__git_refs_remotes "$remote")"
18951899
return
18961900
;;

0 commit comments

Comments
 (0)