git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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.
Previous: Phillip WoodNext: Harald Nordgren via GitGitGadget
Message 17 of 37 in “checkout -m: refine autostash fallback”
  1. 0/2 checkout -m: refine autostash fallbackHarald Nordgren via GitGitGadget, Jul 25, 2026
  2. 1/2 sequencer: teach autostash apply to report conflictsHarald Nordgren via GitGitGadget, Jul 25, 2026
  3. Phillip WoodAug 27, 2026
  4. Harald NordgrenAug 31, 2026
  5. phillip.wood123@gmail.comAug 31, 2026
  6. 2/2 checkout -m: refine autostash fallbackHarald Nordgren via GitGitGadget, Jul 25, 2026
  7. Junio C HamanoJul 28, 2026
  8. Phillip WoodAug 27, 2026
  9. Junio C HamanoAug 26, 2026
  10. Phillip WoodAug 27, 2026
  11. checkout: print blank line after autostash conflict adviceHarald Nordgren via GitGitGadget, Aug 31, 2026
  12. Junio C HamanoAug 31, 2026
  13. Phillip WoodSep 1, 2026
  14. Junio C HamanoSep 1, 2026
  15. checkout: separate autostash conflict advice from branch-switch messageHarald Nordgren via GitGitGadget, Sep 1, 2026
  16. Phillip WoodSep 1, 2026
  17. Junio C HamanoSep 1, 2026
  18. 0/2 checkout -m: refine autostash fallbackHarald Nordgren via GitGitGadget, Sep 2, 2026
  19. 1/2 stash: reserve exit status 1 for conflictsHarald Nordgren via GitGitGadget, Sep 2, 2026
  20. Junio C HamanoSep 2, 2026
  21. Junio C HamanoSep 2, 2026
  22. Phillip WoodSep 3, 2026
  23. Harald NordgrenSep 3, 2026
  24. Junio C HamanoSep 3, 2026
  25. Harald NordgrenSep 3, 2026
  26. Junio C HamanoSep 3, 2026
  27. Harald NordgrenSep 4, 2026
  28. Phillip WoodSep 4, 2026
  29. Harald NordgrenSep 4, 2026
  30. Junio C HamanoSep 4, 2026
  31. 2/2 checkout: separate autostash conflict advice from branch-switch messageHarald Nordgren via GitGitGadget, Sep 2, 2026
  32. Junio C HamanoSep 2, 2026
  33. Phillip WoodSep 3, 2026
  34. 0/2 checkout -m: refine autostash fallbackHarald Nordgren via GitGitGadget, Sep 3, 2026
  35. 1/2 stash: reserve exit status 1 for conflictsHarald Nordgren via GitGitGadget, Sep 3, 2026
  36. 2/2 checkout: separate autostash conflict advice from branch-switch messageHarald Nordgren via GitGitGadget, Sep 3, 2026
  37. Junio C HamanoSep 3, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.