Re: [PATCH 2/2] checkout: tell "parse_remote_branch" which command is calling it
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jan 27, 2026, 21:22 UTC
- Message-ID
- <xmqq343qg38n.fsf@gitster.g>
- In-Reply-To
- <fa7f1648-3cf6-4e5f-bee9-fb5e8700d01d@app.fastmail.com>
"Kristoffer Haugsbakk" <kristofferhaugsbakk@fastmail.com> writes:
Show 10 quoted lines
>> + # 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".
Show 10 quoted lines
>> + 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.