@@ -2223,9 +2223,18 @@ _git_switch ()
__gitcomp_builtin switch
;;
*)
+ local track_opt="--track" only_local_ref=n
+
+ # --orphan is used to create a branch disconnected from the
+ # current history, based on the empty tree. Since the only
+ # option required is the branch name, it doesn't make sense to
+ # complete anything here.
+ if [ -n "$(__git_find_on_cmdline "--orphan")" ]; then
+ return
+ fi
+
# check if --track, --no-track, or --no-guess was specified
# if so, disable DWIM mode
- local track_opt="--track" only_local_ref=n
if [ "$GIT_COMPLETION_CHECKOUT_NO_GUESS" = "1" ] ||
[ -n "$(__git_find_on_cmdline "--track --no-track --no-guess")" ]; then
track_opt=''
@@ -1351,6 +1351,13 @@ test_expect_failure 'git switch - with -C and --no-track, complete all reference
EOF
'
+# TODO: completion does not yet recognize --orphan
+test_expect_failure 'git switch - with --orphan, do not complete anything' '
+ test_completion "git switch --orphan " <<-\EOF
+
+ EOF
+'
+
test_expect_success 'teardown after ref completion' '
git branch -d matching-branch &&
git tag -d matching-tag &&