Skip to content

Commit b921764

Browse files
szedergitster
authored andcommitted
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>
1 parent 3b376b0 commit b921764

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

contrib/completion/git-completion.bash

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,17 @@ _git_bisect ()
506506

507507
_git_branch ()
508508
{
509+
local i c=1 only_local_ref="n" has_r="n"
510+
511+
while [ $c -lt $COMP_CWORD ]; do
512+
i="${COMP_WORDS[c]}"
513+
case "$i" in
514+
-d|-m) only_local_ref="y" ;;
515+
-r) has_r="y" ;;
516+
esac
517+
c=$((++c))
518+
done
519+
509520
case "${COMP_WORDS[COMP_CWORD]}" in
510521
--*=*) COMPREPLY=() ;;
511522
--*)
@@ -514,7 +525,13 @@ _git_branch ()
514525
--track --no-track
515526
"
516527
;;
517-
*) __gitcomp "$(__git_refs)" ;;
528+
*)
529+
if [ $only_local_ref = "y" -a $has_r = "n" ]; then
530+
__gitcomp "$(__git_heads)"
531+
else
532+
__gitcomp "$(__git_refs)"
533+
fi
534+
;;
518535
esac
519536
}
520537

0 commit comments

Comments
 (0)