summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorSZEDER Gábor <szeder@ira.uka.de>2011-10-08 14:54:37 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-10-21 21:38:23 (GMT)
commitabf05987de7b61972e85392ca2f1a4fc25046e57 (patch)
treeba2f406ef3fbab0e1257c9c847a7d07561ec5ec0 /contrib
parenta31e62629a1408bca540f505f2dc4ab8a9999f5d (diff)
downloadgit-abf05987de7b61972e85392ca2f1a4fc25046e57.zip
git-abf05987de7b61972e85392ca2f1a4fc25046e57.tar.gz
git-abf05987de7b61972e85392ca2f1a4fc25046e57.tar.bz2
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 <szeder@ira.uka.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/completion/git-completion.bash6
1 files changed, 2 insertions, 4 deletions
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 7031356..3f7a776 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