]> git.ipfire.org Git - thirdparty/git.git/commit - contrib/completion/git-completion.bash
completion: improve handling of --orphan option of switch/checkout
authorJacob Keller <jacob.keller@gmail.com>
Thu, 28 May 2020 18:10:48 +0000 (11:10 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 28 May 2020 19:57:07 +0000 (12:57 -0700)
commit91439928ecfcb402856dc5dffacdc36ca070d84e
tree5716544b26cf8ef683672a0a4f2a3b5be0d8f17e
parentacb658fe7d6bc11136be0756270fda675af74761
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>
contrib/completion/git-completion.bash
t/t9902-completion.sh