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

Re: What are cherry-pick's exit codes?

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Dec 1, 2022, 14:43 UTC
Message-ID
<40ffe56e-cec2-7130-ca4f-2186a1b7681c@dunelm.org.uk>
In-Reply-To
<878rjry5a7.fsf@gmail.com>
Hi Sean
On 01/12/2022 06:39, Sean Allred wrote:
Show 18 quoted lines
> Hi folks,
> 
> We're developing some internal tooling wrapping git-cherry-pick and need
> to be able to distinguish its different error codes. Problem is: these
> exit codes don't seem to be documented in git-cherry-pick.txt.
> 
> Looking at the source, I found myself down the rabbit-hole very quickly.
> I'm not too familiar with the coding patterns quite yet -- but I'm
> pretty sure I eventually found myself redirected to git-commit in one
> case. At that point, I thought it better to ask here.
> 
> I'd like to document these exit codes in the manpage and I'm more than
> happy to submit the patch, but I thought I'd confirm my understanding
> first since it's based purely on reading the cherry-pick tests:
> 
> Exit code:
> 
>    - 0: success, sequencer complete -- no conflicts
I believe this is correct.
>    - 1: 'success', sequencer incomplete -- conflicts encountered

One can get exit code 1 without conflicts. One example is when it cannot cherry-pick a commit because it would overwrite an untracked file. Another example is when a picked commit would be empty because the changes are already in HEAD.

Show 11 quoted lines
>    - 127: fatal -- lots of reasons -- I'm guessing this is value for the
>      'return -1' and 'return error(...)' statements speckled throughout
>      the code, but it's been a long time since I cared about two's
>      complement so I may be wrong here.
> 
>    - 128: fatal -- sequence is interrupted, possibly due to some other
>      fatal error, e.g., 'commit doesn't exist' or 'mainline parent number
>      doesn't exist'
> 
>    - 129: fatal -- there was nothing to cherry-pick at all (e.g. empty
>      range)

A high exit code from die() indicates something bad happened but I'm not sure one can rely on the exact value to tell you what happened.

Best Wishes
Phillip
Show 20 quoted lines
> I'm reasonably confident about 0/1 just anecdotally -- I'm less sure
> about everything else.
> 
> Obviously the actual text put in the manpage should be friendlier and
> possibly vaguer for clarity (paradoxical, perhaps, but it seems more
> direct to say '0 for success, 1 for conflicts, and anything else is a
> fatal error'), but I wanted to make sure that I have an actually-
> accurate understanding rather than something only surface-level.
> 
> Two questions:
> 
>    1. Are the exit codes actually documented somewhere already that
>       should simply be linked from git-cherry-pick.txt?
> 
>    2. If not, is the above listing the exit codes accurate and complete?
> 
> Thanks!
> 
> --
> Sean Allred
Previous: Sean AllredNext: Sean Allred
Message 4 of 5 in “What are cherry-pick's exit codes?”
  1. Sean AllredDec 1, 2022
  2. Ævar Arnfjörð BjarmasonDec 1, 2022
  3. Sean AllredDec 1, 2022
  4. Phillip WoodDec 1, 2022
  5. Sean AllredDec 1, 2022

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.