Re: [PATCH v3] checkout: separate autostash conflict advice from branch-switch message
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 1, 2026, 17:31 UTC
- Message-ID
- <xmqqtso8swso.fsf@gitster.g>
- In-Reply-To
- <7dbebce0-1814-4b0b-8167-6a464d893612@gmail.com>
Phillip Wood <phillip.wood123@gmail.com> writes:
Show 26 quoted lines
> Hi Harald
>
> On 01/09/2026 10:49, Harald Nordgren via GitGitGadget wrote:
>> From: Harald Nordgren <haraldnordgren@gmail.com>
>>
>> "git checkout -m" stashes the user's local changes when it cannot
>> perform the checkout, and then applies the stash. When applying the
>> stash results in conflicts, the advice on how to deal with them is
>> printed directly on top of the branch-switch message ("Switched to
>> branch ..."), making the two hard to tell apart. Print a blank line
>> in between so that the advice and the branch-switch message are
>> visually distinct.
>>
>> To make this possible, "git stash apply", "pop" and "branch" now exit
>> with status 2 when applying the stash entry resulted in conflicts, in
>> which case the stash entry is left in place; other failures exit with
>> status 1, as before. The exit statuses are documented in the "git
>> stash" documentation.
>
> Other commands such as merge-tree and merge strategies use 1 to indicate
> conflicts and another non-zero exit code for errors. That matches the
> way grep and diff use the exit code to distinguish differences from
> errors. It is confusing if we start using a different convention here.
> I've left a few comments below, but the exit code is my main concern. It
> would be nice to separate out the stash changes into a separate commit
> as well.This is half my fault. I should have made it clear that my sample code was merely to illustrate the need and ability to allow the callers to tell general errors and specific failure modes. I agree with you that "1 if X, other non-zero exit if error" would fly much better.
Thanks.