Merge branch 'dp/clean-fix'
[gitweb.git] / contrib / completion / git-completion.bash
index 8d6733abe4063cebbb0ac2d6e020077ed78fe438..848c067b57398154de6dc5287648b4103841217a 100755 (executable)
@@ -70,7 +70,15 @@ __git_ps1 ()
                local b
                if [ -d "$g/../.dotest" ]
                then
-                       r="|AM/REBASE"
+                       if test -f "$g/../.dotest/rebasing"
+                       then
+                               r="|REBASE"
+                       elif test -f "$g/../.dotest/applying"
+                       then
+                               r="|AM"
+                       else
+                               r="|AM/REBASE"
+                       fi
                        b="$(git symbolic-ref HEAD 2>/dev/null)"
                elif [ -f "$g/.dotest-merge/interactive" ]
                then
@@ -506,6 +514,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 +533,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
 }