mirror of
https://github.com/git/git.git
synced 2026-04-08 16:00:09 +02:00
completion: improve handling of --orphan option of switch/checkout
The --orphan option is used to create a local branch which is detached from the current history. In git switch, it always resets to the empty tree, and thus the only completion we can provide is a branch name. Follow the same rules for -c/-C (and -b/-B) when completing the argument to --orphan. In the case of git switch, after we complete the argument, there is nothing more we can complete for git switch, so do not even try. Nothing else would be valid. In the case of git checkout, --orphan takes a start point which it uses to determine the checked out tree, even though it created orphaned history. Update the previously added test cases as they are now passing. Signed-off-by: Jacob Keller <jacob.keller@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
acb658fe7d
commit
91439928ec
@@ -1669,15 +1669,13 @@ test_expect_success 'git switch - with --orphan completes local branch names and
|
||||
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_expect_success '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_expect_success '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
|
||||
@@ -1686,8 +1684,7 @@ test_expect_failure 'git checkout - with --orphan completes local branch names a
|
||||
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_expect_success '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
|
||||
|
||||
Reference in New Issue
Block a user