summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJacob Keller <jacob.keller@gmail.com>2020-05-28 18:10:39 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-05-28 19:53:24 (GMT)
commitc81ca56bca2d4b9b2606211106ca4ae0fdded834 (patch)
treefc4e236b53acf01beef76160c9ee1eae5bc25def /t
parent7f59d604292774a2c5c79a644419a9aa6c720365 (diff)
downloadgit-c81ca56bca2d4b9b2606211106ca4ae0fdded834.zip
git-c81ca56bca2d4b9b2606211106ca4ae0fdded834.tar.gz
git-c81ca56bca2d4b9b2606211106ca4ae0fdded834.tar.bz2
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>
Diffstat (limited to 't')
-rwxr-xr-xt/t9902-completion.sh39
1 files changed, 39 insertions, 0 deletions
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index dbe6e4d..8375c4d 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -1688,6 +1688,45 @@ test_expect_failure 'git checkout - for -B with --no-track, complete local branc
EOF
'
+#TODO: --orphan argument completion should not include all references
+test_expect_failure 'git switch - with --orphan completes local branch names and unique remote branch names' '
+ test_completion "git switch --orphan " <<-\EOF
+ branch-in-other Z
+ master Z
+ master-in-other Z
+ matching-branch Z
+ EOF
+'
+
+#TODO: switch --orphan does not take a start-point and thus has nothing to complete
+test_expect_failure 'git switch - --orphan with branch already provided completes nothing else' '
+ test_completion "git switch --orphan master " <<-\EOF
+
+ EOF
+'
+
+#TODO: --orphan argument completion should not include all references
+test_expect_failure 'git checkout - with --orphan completes local branch names and unique remote branch names' '
+ test_completion "git checkout --orphan " <<-\EOF
+ branch-in-other Z
+ master Z
+ master-in-other Z
+ matching-branch Z
+ EOF
+'
+
+#TODO: checkout --orphan start-point completion should not included DWIM remote unique branch names
+test_expect_failure 'git checkout - --orphan with branch already provided completes local refs for a start-point' '
+ test_completion "git checkout --orphan master " <<-\EOF
+ HEAD Z
+ master Z
+ matching-branch Z
+ matching-tag Z
+ other/branch-in-other Z
+ other/master-in-other Z
+ EOF
+'
+
test_expect_success 'teardown after ref completion' '
git branch -d matching-branch &&
git tag -d matching-tag &&