Skip to content

Commit e1f74dd

Browse files
bkeringitster
authored andcommitted
completion: bisect: complete bad, new, old, and help subcommands
The bad, new, old and help subcommands to git-bisect(1) are not completed. Add the bad, new, old, and help subcommands to the appropriate lists such that the commands and their possible ref arguments are completed. Add tests. Signed-off-by: Britton Leo Kerin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent db489ea commit e1f74dd

File tree

2 files changed

+73
-2
lines changed

2 files changed

+73
-2
lines changed

contrib/completion/git-completion.bash

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1449,7 +1449,7 @@ _git_bisect ()
14491449
{
14501450
__git_has_doubledash && return
14511451

1452-
local subcommands="start bad good skip reset visualize replay log run"
1452+
local subcommands="start bad new good old skip reset visualize replay log run help"
14531453
local subcommand="$(__git_find_on_cmdline "$subcommands")"
14541454
if [ -z "$subcommand" ]; then
14551455
__git_find_repo_path
@@ -1462,7 +1462,7 @@ _git_bisect ()
14621462
fi
14631463

14641464
case "$subcommand" in
1465-
bad|good|reset|skip|start)
1465+
bad|new|good|old|reset|skip|start)
14661466
__git_complete_refs
14671467
;;
14681468
*)

t/t9902-completion.sh

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,6 +1264,77 @@ test_expect_success 'git switch - with no options, complete local branches and u
12641264
EOF
12651265
'
12661266

1267+
test_expect_success 'git bisect - when not bisecting, complete only replay and start subcommands' '
1268+
test_completion "git bisect " <<-\EOF
1269+
replay Z
1270+
start Z
1271+
EOF
1272+
'
1273+
1274+
test_expect_success 'setup for git-bisect tests requiring a repo' '
1275+
git init git-bisect &&
1276+
(
1277+
cd git-bisect &&
1278+
echo "initial contents" >file &&
1279+
git add file &&
1280+
git commit -am "Initial commit" &&
1281+
git tag initial &&
1282+
echo "new line" >>file &&
1283+
git commit -am "First change" &&
1284+
echo "another new line" >>file &&
1285+
git commit -am "Second change" &&
1286+
git tag final
1287+
)
1288+
'
1289+
1290+
test_expect_success 'git bisect - start subcommand arguments before double-dash are completed as revs' '
1291+
(
1292+
cd git-bisect &&
1293+
test_completion "git bisect start " <<-\EOF
1294+
HEAD Z
1295+
final Z
1296+
initial Z
1297+
master Z
1298+
EOF
1299+
)
1300+
'
1301+
1302+
# Note that these arguments are <pathspec>s, which in practice the fallback
1303+
# completion (not the git completion) later ends up completing as paths.
1304+
test_expect_success 'git bisect - start subcommand arguments after double-dash are not completed' '
1305+
(
1306+
cd git-bisect &&
1307+
test_completion "git bisect start final initial -- " ""
1308+
)
1309+
'
1310+
1311+
test_expect_success 'setup for git-bisect tests requiring ongoing bisection' '
1312+
(
1313+
cd git-bisect &&
1314+
git bisect start --term-new=custom_new --term-old=custom_old final initial
1315+
)
1316+
'
1317+
1318+
test_expect_success 'git-bisect - when bisecting all subcommands are candidates' '
1319+
(
1320+
cd git-bisect &&
1321+
test_completion "git bisect " <<-\EOF
1322+
start Z
1323+
bad Z
1324+
new Z
1325+
good Z
1326+
old Z
1327+
skip Z
1328+
reset Z
1329+
visualize Z
1330+
replay Z
1331+
log Z
1332+
run Z
1333+
help Z
1334+
EOF
1335+
)
1336+
'
1337+
12671338
test_expect_success 'git checkout - completes refs and unique remote branches for DWIM' '
12681339
test_completion "git checkout " <<-\EOF
12691340
HEAD Z

0 commit comments

Comments
 (0)