summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorJay Soffian <jaysoffian@gmail.com>2009-03-05 23:39:33 -0500
committerJunio C Hamano <gitster@pobox.com>2009-03-07 20:23:28 -0800
commit0a4e14727f53ba2e8263622ba5de917b2f9d1575 (patch)
treec82f070c2b952788ce97334b6f8b5c4aae4e9bd4 /contrib
parent3c7b480a1cf6e1a1c73b4edde5d8cf0ac0c8111c (diff)
downloadgit-0a4e14727f53ba2e8263622ba5de917b2f9d1575.tar.gz
bash completion: teach fetch, pull, and push to complete their options
fetch, pull, and push didn't know their options. They do now. merge's options are factored into a variable so they can be shared between _git_merge and _git_pull Signed-off-by: Jay Soffian <jaysoffian@gmail.com> Acked-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/completion/git-completion.bash61
1 files changed, 56 insertions, 5 deletions
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 056e43e4ad..271b911f7a 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -391,10 +391,11 @@ __git_complete_remote_or_refspec ()
{
local cmd="${COMP_WORDS[1]}"
local cur="${COMP_WORDS[COMP_CWORD]}"
- local i c=2 remote="" pfx="" lhs=1
+ local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0
while [ $c -lt $COMP_CWORD ]; do
i="${COMP_WORDS[c]}"
case "$i" in
+ --all|--mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;;
-*) ;;
*) remote="$i"; break ;;
esac
@@ -404,6 +405,10 @@ __git_complete_remote_or_refspec ()
__gitcomp "$(__git_remotes)"
return
fi
+ if [ $no_complete_refspec = 1 ]; then
+ COMPREPLY=()
+ return
+ fi
[ "$remote" = "." ] && remote=
case "$cur" in
*:*)
@@ -904,8 +909,20 @@ _git_diff ()
__git_complete_file
}
+__git_fetch_options="
+ --quiet --verbose --append --upload-pack --force --keep --depth=
+ --tags --no-tags
+"
+
_git_fetch ()
{
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ case "$cur" in
+ --*)
+ __gitcomp "$__git_fetch_options"
+ return
+ ;;
+ esac
__git_complete_remote_or_refspec
}
@@ -1110,6 +1127,11 @@ _git_log ()
__git_complete_revlist
}
+__git_merge_options="
+ --no-commit --no-stat --log --no-log --squash --strategy
+ --commit --stat --no-squash --ff --no-ff
+"
+
_git_merge ()
{
__git_complete_strategy && return
@@ -1117,10 +1139,7 @@ _git_merge ()
local cur="${COMP_WORDS[COMP_CWORD]}"
case "$cur" in
--*)
- __gitcomp "
- --no-commit --no-stat --log --no-log --squash --strategy
- --commit --stat --no-squash --ff --no-ff
- "
+ __gitcomp "$__git_merge_options"
return
esac
__gitcomp "$(__git_refs)"
@@ -1169,11 +1188,43 @@ _git_name_rev ()
_git_pull ()
{
+ __git_complete_strategy && return
+
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ case "$cur" in
+ --*)
+ __gitcomp "
+ --rebase --no-rebase
+ $__git_merge_options
+ $__git_fetch_options
+ "
+ return
+ ;;
+ esac
__git_complete_remote_or_refspec
}
_git_push ()
{
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ case "${COMP_WORDS[COMP_CWORD-1]}" in
+ --repo)
+ __gitcomp "$(__git_remotes)"
+ return
+ esac
+ case "$cur" in
+ --repo=*)
+ __gitcomp "$(__git_remotes)" "" "${cur##--repo=}"
+ return
+ ;;
+ --*)
+ __gitcomp "
+ --all --mirror --tags --dry-run --force --verbose
+ --receive-pack= --repo=
+ "
+ return
+ ;;
+ esac
__git_complete_remote_or_refspec
}