The proposed SQUASH you have in gitster/jk/complete-git-switch is correct. The commit message body is correct, but the title could be reworded to "completion: stop completing refs for git switch --orphan" I can send a v2 if that would be helpful, and I've got it fixed up locally if other review increases the need for a new spin. Thanks, Jake On Mon, Apr 27, 2020 at 4:34 PM Junio C Hamano <gitster@xxxxxxxxx> wrote: > > Jacob Keller <jacob.e.keller@xxxxxxxxx> writes: > > > From: Jacob Keller <jacob.keller@xxxxxxxxx> > > > > git switch with the --orphan option is used to create a new branch that > > is not connected to any history and is instead based on the empty tree. > > > > It does not make sense for completion to return anything in this case, > > because there is nothing to complete. Check for --orphan, and if it's > > found, immediately return from _git_switch() without completing > > anything. > > > > Add a test case which documents this expected behavior. > > > > Signed-off-by: Jacob Keller <jacob.keller@xxxxxxxxx> > > --- > > contrib/completion/git-completion.bash | 11 ++++++++++- > > t/t9902-completion.sh | 7 +++++++ > > 2 files changed, 17 insertions(+), 1 deletion(-) > > > > diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash > > index c21786f2fd00..08d3406cf3e4 100644 > > --- a/contrib/completion/git-completion.bash > > +++ b/contrib/completion/git-completion.bash > > @@ -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='' > > diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh > > index a134a8791076..9d02de167219 100755 > > --- a/t/t9902-completion.sh > > +++ b/t/t9902-completion.sh > > @@ -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 > > +' > > + > > I am getting "TODO passed" at 7276ffe0 (completion: add test showing > subpar completion for git switch --orphan, 2020-04-24), which hasn't > hit 'next' yet. > > Perhaps we got some rebase gotcha here? > > > test_expect_success 'teardown after ref completion' ' > > git branch -d matching-branch && > > git tag -d matching-tag &&