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 <britton.kerin@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Britton Leo Kerin committed Feb 6, 2024 at 12:50 UTC e1f74dd58b77fe9bc5ed196221642395cf8951d0
2 files changed +73 -2
contrib/completion/git-completion.bash
+2 -2
@@ -1449,7 +1449,7 @@ _git_bisect ()
1449 {
1450 __git_has_doubledash && return
1451
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"
1453 local subcommand="$(__git_find_on_cmdline "$subcommands")"
1454 if [ -z "$subcommand" ]; then
1455 __git_find_repo_path
@@ -1462,7 +1462,7 @@ _git_bisect ()
1462 fi
1463
1464 case "$subcommand" in
1465 - bad|good|reset|skip|start)
1465 + bad|new|good|old|reset|skip|start)
1466 __git_complete_refs
1467 ;;
1468 *)
t/t9902-completion.sh
+71
@@ -1264,6 +1264,77 @@ test_expect_success 'git switch - with no options, complete local branches and u
1264 EOF
1265 '
1266
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 +
1338 test_expect_success 'git checkout - completes refs and unique remote branches for DWIM' '
1339 test_completion "git checkout " <<-\EOF
1340 HEAD Z