Exit codes¶
Every lazysubmodules command exits with one of six codes, which are a
stable interface for scripts.
Codes¶
Code |
Meaning |
Typical causes |
|---|---|---|
0 |
Success |
The command did what was asked, including dry runs, |
1 |
Error |
An unknown submodule name, an invalid |
2 |
Usage error |
An unknown command or option, a missing or extra argument, conflicting tracking options, an invalid ref, pattern, commit, path or URL, |
3 |
Refused |
A dirty submodule, a missing ref, a submodule that needs a clone without |
4 |
Verification failed |
A moved tag, a lock file that disagrees with the gitlink or the checkout, a bad signature |
5 |
Git failed |
A |
Refused means unchanged. With status 3,
updatehas moved no submodule and changed neither.gitmodules,.lsm.locknor the index: every selected submodule is checked before the first change. With--fetch, refs that were fetched and submodules that were initialized before the refusal remain.Interrupted commands usually exit with 5, because the
gitprocess they were waiting for was killed; see Signals.States do not count.
statusexits with 0 whatever the states are. Useverify, or read the porcelain format, to fail on a state.foreachexits with 1 when the command fails; the command’s own status is not passed on.
Examples¶
These messages were produced on the demo. Each goes to standard error.
Code |
Command |
Message |
|---|---|---|
1 |
|
|
1 |
|
|
1 |
|
|
1 |
|
|
2 |
|
|
2 |
|
|
2 |
|
|
2 |
|
|
2 |
|
|
3 |
|
|
3 |
|
|
3 |
|
|
3 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
5 |
|
|
The usage errors that come from the command line itself, the first two
rows with code 2, are followed by a second line:
Run 'lazysubmodules help' for usage.
Error format¶
Prefix. Every error line starts with
lazysubmodules:. When a command reports several errors, such as the refusals of an update, each gets its own line and prefix:lazysubmodules: fresh: refused: submodule is not initialized (use --fetch) lazysubmodules: app: refused: submodule has uncommitted changes lazysubmodules: broken: refused: ref not found in local refs: tag v9.9.9 does not exist or does not point to a commit
Submodule. Messages about one submodule name it after the prefix.
Git errors include the
gitcommand line, its exit status and the first lines of its error output.Safe text. Characters that are not printable are replaced, so that an error cannot send control sequences to the terminal.
Using the codes in a shell¶
lazysubmodules update --fetch --commit
case $? in
0) echo "updated" ;;
3) echo "refused: fix the reported submodules and run again" >&2 ;;
*) echo "update failed" >&2; exit 1 ;;
esac
status=0
lazysubmodules verify || status=$?
if [ "$status" -eq 4 ]; then
echo "lock file, gitlinks or tags disagree" >&2
fi
exit "$status"
Stability¶
The codes 0 to 5 and their meanings are part of the user interface, like the porcelain format.
See also¶
General rules: usage rules shared by all commands.
Troubleshooting: how to resolve refusals and failures.
Scripts and CI: exit codes in CI.