Teach bash how to complete +refspec on git-push
authorShawn O. Pearce <spearce@spearce.org>
Sun, 24 Jun 2007 23:42:16 +0000 (19:42 -0400)
committerShawn O. Pearce <spearce@spearce.org>
Sun, 24 Jun 2007 23:42:16 +0000 (19:42 -0400)
Using `git push origin +foo` to forcefully overwrite the remote
branch named foo is a common idiom, especially since + is shorter
than the long option --force and can be specified on a per-branch
basis.

We now complete `git push origin +foo` just like we do the standard
`git push origin foo`.  The leading + on a branch refspec does not
alter the completion.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
contrib/completion/git-completion.bash

index c7c9963347f036323ee5680a3b2918f20cd77eb1..f2b10fa5f67942dc1c8d9d4f16048a6e7e976084 100755 (executable)
@@ -682,6 +682,9 @@ _git_push ()
                        esac
                        __gitcomp "$(__git_refs "$remote")" "" "${cur#*:}"
                        ;;
+               +*)
+                       __gitcomp "$(__git_refs)" + "${cur#+}"
+                       ;;
                *)
                        __gitcomp "$(__git_refs)"
                        ;;