Jay Soffian <jaysoffian@xxxxxxxxx> wrote: > The code to complete --strategy was duplicated between _git_rebase and > _git_merge, and is about to gain a third caller (_git_pull). This patch > factors it into its own function. > > Signed-off-by: Jay Soffian <jaysoffian@xxxxxxxxx> Looks OK to me, but I had to squash this in to get it to work. Without this the patch breaks git merge completion entirely: diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 9e16576..80d464b 100755 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -449,15 +449,15 @@ __git_complete_strategy () case "${COMP_WORDS[COMP_CWORD-1]}" in -s|--strategy) __gitcomp "$(__git_merge_strategies)" - return 1 + return 0 esac case "$cur" in --strategy=*) __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}" - return 1 + return 0 ;; esac - return 0 + return 1 } __git_all_commands () @@ -1111,9 +1111,8 @@ _git_log () _git_merge () { - __git_complete_strategy && return - local cur="${COMP_WORDS[COMP_CWORD]}" + __git_complete_strategy && return case "$cur" in --*) __gitcomp " > --- > contrib/completion/git-completion.bash | 37 ++++++++++++++++--------------- > 1 files changed, 19 insertions(+), 18 deletions(-) > > diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash > index b347fdd..8924185 100755 > --- a/contrib/completion/git-completion.bash > +++ b/contrib/completion/git-completion.bash > @@ -440,6 +440,22 @@ __git_complete_remote_or_refspec () > esac > } > > +__git_complete_strategy () > +{ > + case "${COMP_WORDS[COMP_CWORD-1]}" in > + -s|--strategy) > + __gitcomp "$(__git_merge_strategies)" > + return 1 > + esac > + case "$cur" in > + --strategy=*) > + __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}" > + return 1 > + ;; > + esac > + return 0 > +} > + > __git_all_commands () > { > if [ -n "$__git_all_commandlist" ]; then > @@ -1086,17 +1102,10 @@ _git_log () > > _git_merge () > { > + __git_complete_strategy && return > + > local cur="${COMP_WORDS[COMP_CWORD]}" > - case "${COMP_WORDS[COMP_CWORD-1]}" in > - -s|--strategy) > - __gitcomp "$(__git_merge_strategies)" > - return > - esac > case "$cur" in > - --strategy=*) > - __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}" > - return > - ;; > --*) > __gitcomp " > --no-commit --no-stat --log --no-log --squash --strategy > @@ -1165,16 +1174,8 @@ _git_rebase () > __gitcomp "--continue --skip --abort" > return > fi > - case "${COMP_WORDS[COMP_CWORD-1]}" in > - -s|--strategy) > - __gitcomp "$(__git_merge_strategies)" > - return > - esac > + __git_complete_strategy && return > case "$cur" in > - --strategy=*) > - __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}" > - return > - ;; > --*) > __gitcomp "--onto --merge --strategy --interactive" > return > -- > 1.6.2.rc2.332.g5d21b > -- Shawn. -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html