@@ -11,6 +11,11 @@ test_description='test bash completion'
11
11
# untraceable with such ancient Bash versions.
12
12
test_untraceable=UnfortunatelyYes
13
13
14
+ # Override environment and always use master for the default initial branch
15
+ # name for these tests, so that rev completion candidates are as expected.
16
+ GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
17
+ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
18
+
14
19
. ./lib-bash.sh
15
20
16
21
complete ()
@@ -1267,6 +1272,142 @@ test_expect_success 'git switch - with no options, complete local branches and u
1267
1272
EOF
1268
1273
'
1269
1274
1275
+ test_expect_success ' git bisect - when not bisecting, complete only replay and start subcommands' '
1276
+ test_completion "git bisect " <<-\EOF
1277
+ replay Z
1278
+ start Z
1279
+ EOF
1280
+ '
1281
+
1282
+ test_expect_success ' git bisect - complete options to start subcommand' '
1283
+ test_completion "git bisect start --" <<-\EOF
1284
+ --term-new Z
1285
+ --term-bad Z
1286
+ --term-old Z
1287
+ --term-good Z
1288
+ --no-checkout Z
1289
+ --first-parent Z
1290
+ EOF
1291
+ '
1292
+
1293
+ test_expect_success ' setup for git-bisect tests requiring a repo' '
1294
+ git init git-bisect &&
1295
+ (
1296
+ cd git-bisect &&
1297
+ echo "initial contents" >file &&
1298
+ git add file &&
1299
+ git commit -am "Initial commit" &&
1300
+ git tag initial &&
1301
+ echo "new line" >>file &&
1302
+ git commit -am "First change" &&
1303
+ echo "another new line" >>file &&
1304
+ git commit -am "Second change" &&
1305
+ git tag final
1306
+ )
1307
+ '
1308
+
1309
+ test_expect_success ' git bisect - start subcommand arguments before double-dash are completed as revs' '
1310
+ (
1311
+ cd git-bisect &&
1312
+ test_completion "git bisect start " <<-\EOF
1313
+ HEAD Z
1314
+ final Z
1315
+ initial Z
1316
+ master Z
1317
+ EOF
1318
+ )
1319
+ '
1320
+
1321
+ # Note that these arguments are <pathspec>s, which in practice the fallback
1322
+ # completion (not the git completion) later ends up completing as paths.
1323
+ test_expect_success ' git bisect - start subcommand arguments after double-dash are not completed' '
1324
+ (
1325
+ cd git-bisect &&
1326
+ test_completion "git bisect start final initial -- " ""
1327
+ )
1328
+ '
1329
+
1330
+ test_expect_success ' setup for git-bisect tests requiring ongoing bisection' '
1331
+ (
1332
+ cd git-bisect &&
1333
+ git bisect start --term-new=custom_new --term-old=custom_old final initial
1334
+ )
1335
+ '
1336
+
1337
+ test_expect_success ' git-bisect - when bisecting all subcommands are candidates' '
1338
+ (
1339
+ cd git-bisect &&
1340
+ test_completion "git bisect " <<-\EOF
1341
+ start Z
1342
+ bad Z
1343
+ custom_new Z
1344
+ custom_old Z
1345
+ new Z
1346
+ good Z
1347
+ old Z
1348
+ terms Z
1349
+ skip Z
1350
+ reset Z
1351
+ visualize Z
1352
+ replay Z
1353
+ log Z
1354
+ run Z
1355
+ help Z
1356
+ EOF
1357
+ )
1358
+ '
1359
+
1360
+ test_expect_success ' git-bisect - options to terms subcommand are candidates' '
1361
+ (
1362
+ cd git-bisect &&
1363
+ test_completion "git bisect terms --" <<-\EOF
1364
+ --term-bad Z
1365
+ --term-good Z
1366
+ --term-new Z
1367
+ --term-old Z
1368
+ EOF
1369
+ )
1370
+ '
1371
+
1372
+ test_expect_success ' git-bisect - git-log options to visualize subcommand are candidates' '
1373
+ (
1374
+ cd git-bisect &&
1375
+ # The completion used for git-log and here does not complete
1376
+ # every git-log option, so rather than hope to stay in sync
1377
+ # with exactly what it does we will just spot-test here.
1378
+ test_completion "git bisect visualize --sta" <<-\EOF &&
1379
+ --stat Z
1380
+ EOF
1381
+ test_completion "git bisect visualize --summar" <<-\EOF
1382
+ --summary Z
1383
+ EOF
1384
+ )
1385
+ '
1386
+
1387
+ test_expect_success ' git-bisect - view subcommand is not a candidate' '
1388
+ (
1389
+ cd git-bisect &&
1390
+ test_completion "git bisect vi" <<-\EOF
1391
+ visualize Z
1392
+ EOF
1393
+ )
1394
+ '
1395
+
1396
+ test_expect_success ' git-bisect - existing view subcommand is recognized and enables completion of git-log options' '
1397
+ (
1398
+ cd git-bisect &&
1399
+ # The completion used for git-log and here does not complete
1400
+ # every git-log option, so rather than hope to stay in sync
1401
+ # with exactly what it does we will just spot-test here.
1402
+ test_completion "git bisect view --sta" <<-\EOF &&
1403
+ --stat Z
1404
+ EOF
1405
+ test_completion "git bisect view --summar" <<-\EOF
1406
+ --summary Z
1407
+ EOF
1408
+ )
1409
+ '
1410
+
1270
1411
test_expect_success ' git checkout - completes refs and unique remote branches for DWIM' '
1271
1412
test_completion "git checkout " <<-\EOF
1272
1413
HEAD Z
0 commit comments