I'm writing a program to be able to merge custom binary files. I want to let Git trust the exit code of my program, but it seems badly documented which exit codes do indicate a success.
The doc for git-mergetool states:
If the custom merge tool correctly indicates the success of a merge resolution with its exit code, then the configuration variable
mergetool.<tool>.trustExitCode
can be set totrue
. Otherwise, git mergetool will prompt the user to indicate the success of the resolution after the custom tool has exited.
But this doesn't tell me which exit codes to use for which case. Any ideas?
Git follows the Unix/POSIX standard conventions: 0 = success, nonzero generally implies some kind of failure.
Often (but not in Git) 2 is used for improper-usage diagnostics and/or --help
output; equally often, though, --help
results in successful exit, and this is the case for Git. (Meanwhile git not-a-git-command
results in status 1. That is, failure-that-produces-some-help results in exit 1, while a request for help produces exit 0, in Git.)
The git bisect
command has one other special exit code, namely 125, that it interprets unusually when returned from a command invoked by git bisect run
; see the documentation for why 125 means what it does here.