@matheusbsbs / matheus-bagliano / commits / b07d77a2ba
Fork 0

completion: add tests showing subpar -c/-C startpoint completion

When using the branch creation argument for git switch or git checkout, -c/-C or -b/-B, the commands operate in a different mode: `git switch -c <branch> <some-reference>` means to create a branch named <branch> at the commit referred to by <some-reference>. When completing the start-point, we ought to always complete all valid references. Add tests for the completion of the start-point to -c/-C and -b/-B. 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 b07d77a2baae626370be8ae35efd3ebaf9befbc2
1 file changed +140
t/t9902-completion.sh
+140
@@ -1448,6 +1448,146 @@ test_expect_success 'git checkout - with --no-track, complete only local referen
1448 EOF
1449 '
1450
1451 +#TODO: completing the start point of -c/-C should not include DWIM references
1452 +test_expect_failure 'git switch - with -c, complete all references' '
1453 + test_completion "git switch -c new-branch " <<-\EOF
1454 + HEAD Z
1455 + master Z
1456 + matching-branch Z
1457 + matching-tag Z
1458 + other/branch-in-other Z
1459 + other/master-in-other Z
1460 + EOF
1461 +'
1462 +
1463 +#TODO: completing the start point of -c/-C should not include DWIM references
1464 +test_expect_failure 'git switch - with -C, complete all references' '
1465 + test_completion "git switch -C new-branch " <<-\EOF
1466 + HEAD Z
1467 + master Z
1468 + matching-branch Z
1469 + matching-tag Z
1470 + other/branch-in-other Z
1471 + other/master-in-other Z
1472 + EOF
1473 +'
1474 +
1475 +#TODO: completing the start point of -c/-C should include all references, not just local branches
1476 +test_expect_failure 'git switch - with -c and --track, complete all references' '
1477 + test_completion "git switch -c new-branch --track " <<-EOF
1478 + HEAD Z
1479 + master Z
1480 + matching-branch Z
1481 + matching-tag Z
1482 + other/branch-in-other Z
1483 + other/master-in-other Z
1484 + EOF
1485 +'
1486 +
1487 +#TODO: completing the start point of -c/-C should include all references, not just local branches
1488 +test_expect_failure 'git switch - with -C and --track, complete all references' '
1489 + test_completion "git switch -C new-branch --track " <<-EOF
1490 + HEAD Z
1491 + master Z
1492 + matching-branch Z
1493 + matching-tag Z
1494 + other/branch-in-other Z
1495 + other/master-in-other Z
1496 + EOF
1497 +'
1498 +
1499 +#TODO: completing the start point of -c/-C should include all references, not just local branches
1500 +test_expect_failure 'git switch - with -c and --no-track, complete all references' '
1501 + test_completion "git switch -c new-branch --no-track " <<-\EOF
1502 + HEAD Z
1503 + master Z
1504 + matching-branch Z
1505 + matching-tag Z
1506 + other/branch-in-other Z
1507 + other/master-in-other Z
1508 + EOF
1509 +'
1510 +
1511 +#TODO: completing the start point of -c/-C should include all references, not just local branches
1512 +test_expect_failure 'git switch - with -C and --no-track, complete all references' '
1513 + test_completion "git switch -C new-branch --no-track " <<-\EOF
1514 + HEAD Z
1515 + master Z
1516 + matching-branch Z
1517 + matching-tag Z
1518 + other/branch-in-other Z
1519 + other/master-in-other Z
1520 + EOF
1521 +'
1522 +
1523 +#TODO: completing the start point of -b/-B should not include DWIM references
1524 +test_expect_failure 'git checkout - with -b, complete all references' '
1525 + test_completion "git checkout -b new-branch " <<-\EOF
1526 + HEAD Z
1527 + master Z
1528 + matching-branch Z
1529 + matching-tag Z
1530 + other/branch-in-other Z
1531 + other/master-in-other Z
1532 + EOF
1533 +'
1534 +
1535 +#TODO: completing the start point of -b/-B should not include DWIM references
1536 +test_expect_failure 'git checkout - with -B, complete all references' '
1537 + test_completion "git checkout -B new-branch " <<-\EOF
1538 + HEAD Z
1539 + master Z
1540 + matching-branch Z
1541 + matching-tag Z
1542 + other/branch-in-other Z
1543 + other/master-in-other Z
1544 + EOF
1545 +'
1546 +
1547 +test_expect_success 'git checkout - with -b and --track, complete all references' '
1548 + test_completion "git checkout -b new-branch --track " <<-EOF
1549 + HEAD Z
1550 + master Z
1551 + matching-branch Z
1552 + matching-tag Z
1553 + other/branch-in-other Z
1554 + other/master-in-other Z
1555 + EOF
1556 +'
1557 +
1558 +test_expect_success 'git checkout - with -B and --track, complete all references' '
1559 + test_completion "git checkout -B new-branch --track " <<-EOF
1560 + HEAD Z
1561 + master Z
1562 + matching-branch Z
1563 + matching-tag Z
1564 + other/branch-in-other Z
1565 + other/master-in-other Z
1566 + EOF
1567 +'
1568 +
1569 +test_expect_success 'git checkout - with -b and --no-track, complete all references' '
1570 + test_completion "git checkout -b new-branch --no-track " <<-\EOF
1571 + HEAD Z
1572 + master Z
1573 + matching-branch Z
1574 + matching-tag Z
1575 + other/branch-in-other Z
1576 + other/master-in-other Z
1577 + EOF
1578 +'
1579 +
1580 +test_expect_success 'git checkout - with -B and --no-track, complete all references' '
1581 + test_completion "git checkout -B new-branch --no-track " <<-\EOF
1582 + HEAD Z
1583 + master Z
1584 + matching-branch Z
1585 + matching-tag Z
1586 + other/branch-in-other Z
1587 + other/master-in-other Z
1588 + EOF
1589 +'
1590 +
1591 test_expect_success 'teardown after ref completion' '
1592 git branch -d matching-branch &&
1593 git tag -d matching-tag &&