Skip to content

Commit

Permalink
completion: fast initial completion for config 'remote.*.fetch' value
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
SZEDER Gábor authored and Junio C Hamano committed Oct 21, 2011
1 parent 48058f5 commit d51a8ec
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions contrib/completion/git-completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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
;;
Expand Down

0 comments on commit d51a8ec

Please sign in to comment.