Skip to content

Commit

Permalink
Support --strategy=x completion in addition to --strategy x.
Browse files Browse the repository at this point in the history
Because git-merge and git-rebase both accept -s, --strategy or --strategy=
we should recognize all three formats in the bash completion functions and
issue back all merge strategies on demand.

I also moved the prior word testing to be before the current word testing,
as the current word cannot be completed with -- if the prior word was an
option which requires a parameter, such as -s or --strategy.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Shawn O. Pearce authored and Junio C Hamano committed Nov 27, 2006
1 parent 5de40f5 commit ce1e39d
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions contrib/completion/git-completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -435,18 +435,23 @@ _git_log ()
_git_merge ()
{
local cur="${COMP_WORDS[COMP_CWORD]}"
case "${COMP_WORDS[COMP_CWORD-1]}" in
-s|--strategy)
COMPREPLY=($(compgen -W "$(__git_merge_strategies)" -- "$cur"))
return
esac
case "$cur" in
--strategy=*)
COMPREPLY=($(compgen -W "$(__git_merge_strategies)" \
-- "${cur##--strategy=}"))
return
;;
--*)
COMPREPLY=($(compgen -W "
--no-commit --no-summary --squash --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"))
}

Expand Down Expand Up @@ -523,18 +528,23 @@ _git_rebase ()
" -- "$cur"))
return
fi
case "${COMP_WORDS[COMP_CWORD-1]}" in
-s|--strategy)
COMPREPLY=($(compgen -W "$(__git_merge_strategies)" -- "$cur"))
return
esac
case "$cur" in
--strategy=*)
COMPREPLY=($(compgen -W "$(__git_merge_strategies)" \
-- "${cur##--strategy=}"))
return
;;
--*)
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"))
}

Expand Down

0 comments on commit ce1e39d

Please sign in to comment.