completion: add tests showing subar checkout --detach logic
When completing words for git switch, the completion function correctly disables the DWIM remote branch names when in the '--detach' mode. These DWIM remote branch names will not work when the --detach option is specified, so it does not make sense to complete them. git checkout, however, does not disable the completion of DWIM remote branch names in this case. Add test cases for both git switch and git checkout showing the expected behavior. Signed-off-by: Jacob Keller <jacob.keller@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jacob Keller committed
May 28, 2020 at 11:10 UTC
e69fb0a16abb6412fa6c297cfe7ff43ba762a9b3
1 file changed
+46
t/t9902-completion.sh
+46
@@ -1368,6 +1368,52 @@ test_expect_success 'git checkout - a later --no-guess overrides previous --gues
1368
EOF
1369
'
1370
1371
+test_expect_success 'git switch - with --detach, complete all references' '
1372
+ test_completion "git switch --detach " <<-\EOF
1373
+ HEAD Z
1374
+ master Z
1375
+ matching-branch Z
1376
+ matching-tag Z
1377
+ other/branch-in-other Z
1378
+ other/master-in-other Z
1379
+ EOF
1380
+'
1381
+
1382
+#TODO: checkout --detach incorrectly includes DWIM remote branch names
1383
+test_expect_failure 'git checkout - with --detach, complete only references' '
1384
+ test_completion "git checkout --detach " <<-\EOF
1385
+ HEAD Z
1386
+ master Z
1387
+ matching-branch Z
1388
+ matching-tag Z
1389
+ other/branch-in-other Z
1390
+ other/master-in-other Z
1391
+ EOF
1392
+'
1393
+
1394
+test_expect_success 'git switch - with -d, complete all references' '
1395
+ test_completion "git switch -d " <<-\EOF
1396
+ HEAD Z
1397
+ master Z
1398
+ matching-branch Z
1399
+ matching-tag Z
1400
+ other/branch-in-other Z
1401
+ other/master-in-other Z
1402
+ EOF
1403
+'
1404
+
1405
+#TODO: checkout -d incorrectly includes DWIM remote branch names
1406
+test_expect_failure 'git checkout - with -d, complete only references' '
1407
+ test_completion "git checkout -d " <<-\EOF
1408
+ HEAD Z
1409
+ master Z
1410
+ matching-branch Z
1411
+ matching-tag Z
1412
+ other/branch-in-other Z
1413
+ other/master-in-other Z
1414
+ EOF
1415
+'
1416
+
1417
test_expect_success 'teardown after ref completion' '
1418
git branch -d matching-branch &&
1419
git tag -d matching-tag &&