completion: add tests showing subpar switch/checkout --orphan logic
Similar to -c/-C, --orphan takes an argument which is the branch name to use. We ought to complete this branch name using similar rules as to how we complete new branch names for -c/-C and -b/-B. Namely, limit the total number of options provided by completing to the local branches. Additionally, git switch --orphan does not take any start point and will always create using the empty-tree. Thus, after the branch name is completed, git switch --orphan should not complete any references. Add test cases showing the expected behavior of --orphan, for both the argument and starting point. 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
c81ca56bca2d4b9b2606211106ca4ae0fdded834
1 file changed
+39
t/t9902-completion.sh
+39
@@ -1688,6 +1688,45 @@ test_expect_failure 'git checkout - for -B with --no-track, complete local branc
1688
EOF
1689
'
1690
1691
+#TODO: --orphan argument completion should not include all references
1692
+test_expect_failure 'git switch - with --orphan completes local branch names and unique remote branch names' '
1693
+ test_completion "git switch --orphan " <<-\EOF
1694
+ branch-in-other Z
1695
+ master Z
1696
+ master-in-other Z
1697
+ matching-branch Z
1698
+ EOF
1699
+'
1700
+
1701
+#TODO: switch --orphan does not take a start-point and thus has nothing to complete
1702
+test_expect_failure 'git switch - --orphan with branch already provided completes nothing else' '
1703
+ test_completion "git switch --orphan master " <<-\EOF
1704
+
1705
+ EOF
1706
+'
1707
+
1708
+#TODO: --orphan argument completion should not include all references
1709
+test_expect_failure 'git checkout - with --orphan completes local branch names and unique remote branch names' '
1710
+ test_completion "git checkout --orphan " <<-\EOF
1711
+ branch-in-other Z
1712
+ master Z
1713
+ master-in-other Z
1714
+ matching-branch Z
1715
+ EOF
1716
+'
1717
+
1718
+#TODO: checkout --orphan start-point completion should not included DWIM remote unique branch names
1719
+test_expect_failure 'git checkout - --orphan with branch already provided completes local refs for a start-point' '
1720
+ test_completion "git checkout --orphan master " <<-\EOF
1721
+ HEAD Z
1722
+ master Z
1723
+ matching-branch Z
1724
+ matching-tag Z
1725
+ other/branch-in-other Z
1726
+ other/master-in-other Z
1727
+ EOF
1728
+'
1729
+
1730
test_expect_success 'teardown after ref completion' '
1731
git branch -d matching-branch &&
1732
git tag -d matching-tag &&