]> git.ipfire.org Git - thirdparty/git.git/blobdiff - contrib/completion/git-completion.bash
bash: add git-branch options
[thirdparty/git.git] / contrib / completion / git-completion.bash
index 58e0e53cd6f6382e9665d20b53b26cd1da42fc88..8d6733abe4063cebbb0ac2d6e020077ed78fe438 100755 (executable)
@@ -64,12 +64,44 @@ __gitdir ()
 
 __git_ps1 ()
 {
-       local b="$(git symbolic-ref HEAD 2>/dev/null)"
-       if [ -n "$b" ]; then
+       local g="$(git rev-parse --git-dir 2>/dev/null)"
+       if [ -n "$g" ]; then
+               local r
+               local b
+               if [ -d "$g/../.dotest" ]
+               then
+                       r="|AM/REBASE"
+                       b="$(git symbolic-ref HEAD 2>/dev/null)"
+               elif [ -f "$g/.dotest-merge/interactive" ]
+               then
+                       r="|REBASE-i"
+                       b="$(cat $g/.dotest-merge/head-name)"
+               elif [ -d "$g/.dotest-merge" ]
+               then
+                       r="|REBASE-m"
+                       b="$(cat $g/.dotest-merge/head-name)"
+               elif [ -f "$g/MERGE_HEAD" ]
+               then
+                       r="|MERGING"
+                       b="$(git symbolic-ref HEAD 2>/dev/null)"
+               else
+                       if [ -f $g/BISECT_LOG ]
+                       then
+                               r="|BISECTING"
+                       fi
+                       if ! b="$(git symbolic-ref HEAD 2>/dev/null)"
+                       then
+                               if ! b="$(git describe --exact-match HEAD 2>/dev/null)"
+                               then
+                                       b="$(cut -c1-7 $g/HEAD)..."
+                               fi
+                       fi
+               fi
+
                if [ -n "$1" ]; then
-                       printf "$1" "${b##refs/heads/}"
+                       printf "$1" "${b##refs/heads/}$r"
                else
-                       printf " (%s)" "${b##refs/heads/}"
+                       printf " (%s)" "${b##refs/heads/}$r"
                fi
        fi
 }
@@ -291,7 +323,7 @@ __git_commands ()
        for i in $(git help -a|egrep '^ ')
        do
                case $i in
-               add--interactive) : plumbing;;
+               *--*)             : helper pattern;;
                applymbox)        : ask gittus;;
                applypatch)       : ask gittus;;
                archimport)       : import;;
@@ -308,7 +340,6 @@ __git_commands ()
                diff-tree)        : plumbing;;
                fast-import)      : import;;
                fsck-objects)     : plumbing;;
-               fetch--tool)      : plumbing;;
                fetch-pack)       : plumbing;;
                fmt-merge-msg)    : plumbing;;
                for-each-ref)     : plumbing;;
@@ -334,7 +365,7 @@ __git_commands ()
                read-tree)        : plumbing;;
                receive-pack)     : plumbing;;
                reflog)           : plumbing;;
-               repo-config)      : plumbing;;
+               repo-config)      : deprecated;;
                rerere)           : plumbing;;
                rev-list)         : plumbing;;
                rev-parse)        : plumbing;;
@@ -475,7 +506,16 @@ _git_bisect ()
 
 _git_branch ()
 {
-       __gitcomp "$(__git_refs)"
+       case "${COMP_WORDS[COMP_CWORD]}" in
+       --*=*)  COMPREPLY=() ;;
+       --*)
+               __gitcomp "
+                       --color --no-color --verbose --abbrev= --no-abbrev
+                       --track --no-track
+                       "
+               ;;
+       *)      __gitcomp "$(__git_refs)" ;;
+       esac
 }
 
 _git_bundle ()
@@ -617,6 +657,7 @@ _git_format_patch ()
                        --in-reply-to=
                        --full-index --binary
                        --not --all
+                       --cover-letter
                        "
                return
                ;;
@@ -971,18 +1012,18 @@ _git_remote ()
        while [ $c -lt $COMP_CWORD ]; do
                i="${COMP_WORDS[c]}"
                case "$i" in
-               add|show|prune|update) command="$i"; break ;;
+               add|rm|show|prune|update) command="$i"; break ;;
                esac
                c=$((++c))
        done
 
        if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
-               __gitcomp "add show prune update"
+               __gitcomp "add rm show prune update"
                return
        fi
 
        case "$command" in
-       show|prune)
+       rm|show|prune)
                __gitcomp "$(__git_remotes)"
                ;;
        update)