aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2006-11-27 03:42:07 -0500
committerJunio C Hamano <junkio@cox.net>2006-11-27 12:11:07 -0800
commit61d926a3cdb8f03147580de53e448fc22370cbb1 (patch)
tree7913242c12d11df1e983ef0c3569bf4f11a4bb7a
parent1273231ee9c7a576a3654d8f2ba77267393564ab (diff)
downloadgit-61d926a3cdb8f03147580de53e448fc22370cbb1.tar.gz
git-61d926a3cdb8f03147580de53e448fc22370cbb1.tar.xz
Teach bash how to complete git-rebase.
As git-rebase is a popular command bash should know how to complete reference names and its long options. We only support completions which make sense given the current state of the repository, that way users don't get shown --continue/--skip/--abort on the first execution. Also added support for long option --strategy to git-merge, as I missed that option earlier and just noticed it while implementing git-rebase. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
-rwxr-xr-xcontrib/completion/git-completion.bash38
1 files changed, 32 insertions, 6 deletions
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 5582561ac..9f63ff62f 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -367,16 +367,16 @@ _git_merge ()
case "$cur" in
--*)
COMPREPLY=($(compgen -W "
- --no-commit --no-summary --squash
+ --no-commit --no-summary --squash --strategy
" -- "$cur"))
return
esac
- if [ $COMP_CWORD -gt 1 -a X-s = "X${COMP_WORDS[COMP_CWORD-1]}" ]
- then
+ case "${COMP_WORDS[COMP_CWORD-1]}" in
+ -s|--strategy)
COMPREPLY=($(compgen -W "$(__git_merge_strategies)" -- "$cur"))
- else
- COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
- fi
+ return
+ esac
+ COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
}
_git_merge_base ()
@@ -443,6 +443,30 @@ _git_push ()
esac
}
+_git_rebase ()
+{
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ if [ -d .dotest ]; then
+ COMPREPLY=($(compgen -W "
+ --continue --skip --abort
+ " -- "$cur"))
+ return
+ fi
+ case "$cur" in
+ --*)
+ COMPREPLY=($(compgen -W "
+ --onto --merge --strategy
+ " -- "$cur"))
+ return
+ esac
+ case "${COMP_WORDS[COMP_CWORD-1]}" in
+ -s|--strategy)
+ COMPREPLY=($(compgen -W "$(__git_merge_strategies)" -- "$cur"))
+ return
+ esac
+ COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
+}
+
_git_reset ()
{
local cur="${COMP_WORDS[COMP_CWORD]}"
@@ -500,6 +524,7 @@ _git ()
name-rev) _git_name_rev ;;
pull) _git_pull ;;
push) _git_push ;;
+ rebase) _git_rebase ;;
reset) _git_reset ;;
show) _git_show ;;
show-branch) _git_log ;;
@@ -532,6 +557,7 @@ complete -o default -F _git_merge_base git-merge-base
complete -o default -F _git_name_rev git-name-rev
complete -o default -o nospace -F _git_pull git-pull
complete -o default -o nospace -F _git_push git-push
+complete -o default -F _git_rebase git-rebase
complete -o default -F _git_reset git-reset
complete -o default -F _git_show git-show
complete -o default -o nospace -F _git_log git-show-branch