Subject: Re: [PATCH 2/2] checkout: tell "parse_remote_branch" which command is calling it

From: Junio C Hamano <[email-masked]>
Date: Tue, 27 Jan 2026 13:22:32 -0800

"Kristoffer Haugsbakk" <[email-masked]> writes:

>> +	# DWIM
>> +	test_must_fail git checkout trunk 2>hint &&
>> +	test_grep "hint: *git checkout --track" hint &&
>> +	test_grep ! "hint: *git switch --track" hint &&
>> +
>> +	{ git update-ref -d refs/heads/trunk || :; } &&
>
> I don’t understand what the purpose of this is after `git checkout` but
> before `git switch`. I can delete it and the test still passes. Is it
> post-test cleanup?

Just in case "git checkout trunk" that was expected to fail still
creates the 'trunk' branch by a bug.  I do not want the failure of
the next "git switch trunk" to be due to "hey, you already have a
local branch of that name", and make sure the failure is from "you
have two remotes with trunk, and I cannot tell which one you meant".

>> +	test_must_fail git switch trunk 2>hint &&
>> +	test_grep ! "hint: *git checkout --track" hint &&
>> +	test_grep "hint: *git switch --track" hint
>> +'
>
> Maybe just the positive greps are enough. I read these a few times
> because I thought the order was wrong, i.e. that `hint` was overwritten
> before it got tested. The regression that they test are unlikely and
> these negative greps might not make immediate sense for future
> readers. I dunno.

Possibly.  These tests to expect concrete strings in the output are
already familiar with how these output strings are built, so they
should know that when 'git checkout --track' appears, it is very
unlikely that 'git switch --track' would appear there, for example.

Thanks.