@matheusbsbs / matheus-bagliano / commits / b9217642ef
Fork 0

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>

SZEDER Gábor committed Mar 4, 2008 at 19:00 UTC b9217642ef2db34e2cbeaef8d4439b07a03027cd
1 file changed +18 -1
contrib/completion/git-completion.bash
+18 -1
@@ -506,6 +506,17 @@ _git_bisect ()
506
507 _git_branch ()
508 {
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 +
520 case "${COMP_WORDS[COMP_CWORD]}" in
521 --*=*) COMPREPLY=() ;;
522 --*)
@@ -514,7 +525,13 @@ _git_branch ()
525 --track --no-track
526 "
527 ;;
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 + ;;
535 esac
536 }
537