Support --strategy=x completion in addition to --strategy x.
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>
Shawn O. Pearce committed
Nov 27, 2006 at 15:10 UTC
ce1e39d29ee373786ceda9e79d0906a6451ab5a5
1 file changed
+20
-10
contrib/completion/git-completion.bash
+20
-10
@@ -435,18 +435,23 @@ _git_log ()
435
_git_merge ()
436
{
437
local cur="${COMP_WORDS[COMP_CWORD]}"
438
+ case "${COMP_WORDS[COMP_CWORD-1]}" in
439
+ -s|--strategy)
440
+ COMPREPLY=($(compgen -W "$(__git_merge_strategies)" -- "$cur"))
441
+ return
442
+ esac
443
case "$cur" in
444
+ --strategy=*)
445
+ COMPREPLY=($(compgen -W "$(__git_merge_strategies)" \
446
+ -- "${cur##--strategy=}"))
447
+ return
448
+ ;;
449
--*)
450
COMPREPLY=($(compgen -W "
451
--no-commit --no-summary --squash --strategy
452
" -- "$cur"))
453
return
454
esac
445
- case "${COMP_WORDS[COMP_CWORD-1]}" in
446
- -s|--strategy)
447
- COMPREPLY=($(compgen -W "$(__git_merge_strategies)" -- "$cur"))
448
- return
449
- esac
455
COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
456
}
457
@@ -523,18 +528,23 @@ _git_rebase ()
528
" -- "$cur"))
529
return
530
fi
531
+ case "${COMP_WORDS[COMP_CWORD-1]}" in
532
+ -s|--strategy)
533
+ COMPREPLY=($(compgen -W "$(__git_merge_strategies)" -- "$cur"))
534
+ return
535
+ esac
536
case "$cur" in
537
+ --strategy=*)
538
+ COMPREPLY=($(compgen -W "$(__git_merge_strategies)" \
539
+ -- "${cur##--strategy=}"))
540
+ return
541
+ ;;
542
--*)
543
COMPREPLY=($(compgen -W "
544
--onto --merge --strategy
545
" -- "$cur"))
546
return
547
esac
533
- case "${COMP_WORDS[COMP_CWORD-1]}" in
534
- -s|--strategy)
535
- COMPREPLY=($(compgen -W "$(__git_merge_strategies)" -- "$cur"))
536
- return
537
- esac
548
COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
549
}
550