summaryrefslogtreecommitdiff
path: root/contrib/completion/git-completion.bash
diff options
context:
space:
mode:
authorLibravatar SZEDER Gábor <szeder@ira.uka.de>2008-03-04 19:00:59 +0100
committerLibravatar Junio C Hamano <gitster@pobox.com>2008-03-05 12:10:29 -0800
commitb9217642ef2db34e2cbeaef8d4439b07a03027cd (patch)
treeeeb2319961e5ec26e8fd3e4750022e92b4d15220 /contrib/completion/git-completion.bash
parentbash: add git-branch options (diff)
downloadtgif-b9217642ef2db34e2cbeaef8d4439b07a03027cd.tar.xz
bash: git-branch -d and -m lists only local branches
But still all branches are listed, if -r is present Signed-off-by: SZEDER Gábor <szeder@ira.uka.de> Acked-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib/completion/git-completion.bash')
-rwxr-xr-xcontrib/completion/git-completion.bash19
1 files changed, 18 insertions, 1 deletions
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 8d6733abe4..49e6df0965 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -506,6 +506,17 @@ _git_bisect ()
_git_branch ()
{
+ local i c=1 only_local_ref="n" has_r="n"
+
+ while [ $c -lt $COMP_CWORD ]; do
+ i="${COMP_WORDS[c]}"
+ case "$i" in
+ -d|-m) only_local_ref="y" ;;
+ -r) has_r="y" ;;
+ esac
+ c=$((++c))
+ done
+
case "${COMP_WORDS[COMP_CWORD]}" in
--*=*) COMPREPLY=() ;;
--*)
@@ -514,7 +525,13 @@ _git_branch ()
--track --no-track
"
;;
- *) __gitcomp "$(__git_refs)" ;;
+ *)
+ if [ $only_local_ref = "y" -a $has_r = "n" ]; then
+ __gitcomp "$(__git_heads)"
+ else
+ __gitcomp "$(__git_refs)"
+ fi
+ ;;
esac
}