mirror of
https://github.com/git/git
synced 2024-08-27 11:39:22 +00:00
completion: bisect: complete custom terms and related options
git bisect supports the use of custom terms via the --term-(new|bad) and --term-(old|good) options, but the completion code doesn't know about these options or the new subcommands they define. Add support for these options and the custom subcommands by checking for BISECT_TERMS and adding them to the list of subcommands. Add tests. Signed-off-by: Britton Leo Kerin <britton.kerin@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
e1f74dd58b
commit
af8910a2d4
|
@ -1449,7 +1449,20 @@ _git_bisect ()
|
||||||
{
|
{
|
||||||
__git_has_doubledash && return
|
__git_has_doubledash && return
|
||||||
|
|
||||||
local subcommands="start bad new good old skip reset visualize replay log run help"
|
__git_find_repo_path
|
||||||
|
|
||||||
|
# If a bisection is in progress get the terms being used.
|
||||||
|
local term_bad term_good
|
||||||
|
if [ -f "$__git_repo_path"/BISECT_TERMS ]; then
|
||||||
|
term_bad=$(__git bisect terms --term-bad)
|
||||||
|
term_good=$(__git bisect terms --term-good)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# We will complete any custom terms, but still always complete the
|
||||||
|
# more usual bad/new/good/old because git bisect gives a good error
|
||||||
|
# message if these are given when not in use, and that's better than
|
||||||
|
# silent refusal to complete if the user is confused.
|
||||||
|
local subcommands="start bad new $term_bad good old $term_good terms skip reset visualize replay log run help"
|
||||||
local subcommand="$(__git_find_on_cmdline "$subcommands")"
|
local subcommand="$(__git_find_on_cmdline "$subcommands")"
|
||||||
if [ -z "$subcommand" ]; then
|
if [ -z "$subcommand" ]; then
|
||||||
__git_find_repo_path
|
__git_find_repo_path
|
||||||
|
@ -1462,7 +1475,22 @@ _git_bisect ()
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case "$subcommand" in
|
case "$subcommand" in
|
||||||
bad|new|good|old|reset|skip|start)
|
start)
|
||||||
|
case "$cur" in
|
||||||
|
--*)
|
||||||
|
__gitcomp "--term-new --term-bad --term-old --term-good"
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
__git_complete_refs
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
terms)
|
||||||
|
__gitcomp "--term-good --term-old --term-bad --term-new"
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
bad|new|"$term_bad"|good|old|"$term_good"|reset|skip)
|
||||||
__git_complete_refs
|
__git_complete_refs
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
|
|
@ -1321,9 +1321,12 @@ test_expect_success 'git-bisect - when bisecting all subcommands are candidates'
|
||||||
test_completion "git bisect " <<-\EOF
|
test_completion "git bisect " <<-\EOF
|
||||||
start Z
|
start Z
|
||||||
bad Z
|
bad Z
|
||||||
|
custom_new Z
|
||||||
|
custom_old Z
|
||||||
new Z
|
new Z
|
||||||
good Z
|
good Z
|
||||||
old Z
|
old Z
|
||||||
|
terms Z
|
||||||
skip Z
|
skip Z
|
||||||
reset Z
|
reset Z
|
||||||
visualize Z
|
visualize Z
|
||||||
|
@ -1335,6 +1338,18 @@ test_expect_success 'git-bisect - when bisecting all subcommands are candidates'
|
||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'git-bisect - options to terms subcommand are candidates' '
|
||||||
|
(
|
||||||
|
cd git-bisect &&
|
||||||
|
test_completion "git bisect terms --" <<-\EOF
|
||||||
|
--term-bad Z
|
||||||
|
--term-good Z
|
||||||
|
--term-new Z
|
||||||
|
--term-old Z
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'git checkout - completes refs and unique remote branches for DWIM' '
|
test_expect_success 'git checkout - completes refs and unique remote branches for DWIM' '
|
||||||
test_completion "git checkout " <<-\EOF
|
test_completion "git checkout " <<-\EOF
|
||||||
HEAD Z
|
HEAD Z
|
||||||
|
|
Loading…
Reference in a new issue