From: SZEDER Gábor Date: Sat, 8 Oct 2011 14:54:37 +0000 (+0200) Subject: completion: make refs completion consistent for local and remote repos X-Git-Tag: v1.7.9-rc0~81^2~6 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=abf05987de7b61972e85392ca2f1a4fc25046e57;p=git.git completion: make refs completion consistent for local and remote repos For a local repository the __git_refs() completion helper function lists refs under 'refs/(tags|heads|remotes)/', plus some special refs like HEAD and ORIG_HEAD. For a remote repository, however, it lists all refs. Fix this inconsistency by specifying refs filter patterns for 'git ls-remote' to only list refs under 'refs/(tags|heads|remotes)/'. For now this makes it impossible to complete refs outside of 'refs/(tags|heads|remotes)/' in a remote repository, but a followup patch will resurrect that. Signed-off-by: SZEDER Gábor Signed-off-by: Junio C Hamano --- diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 703135655..3f7a776a9 100755 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -616,13 +616,11 @@ __git_refs () fi return fi - for i in $(git ls-remote "$dir" 2>/dev/null); do + for i in $(git ls-remote "$dir" HEAD ORIG_HEAD 'refs/tags/*' 'refs/heads/*' 'refs/remotes/*' 2>/dev/null); do case "$is_hash,$i" in y,*) is_hash=n ;; n,*^{}) is_hash=y ;; - n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;; - n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;; - n,refs/remotes/*) is_hash=y; echo "${i#refs/remotes/}" ;; + n,refs/*) is_hash=y; echo "${i#refs/*/}" ;; n,*) is_hash=y; echo "$i" ;; esac done