diff options
| author | Patrick Steinhardt <ps@pks.im> | 2025-06-03 16:01:18 +0200 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-06-03 08:30:51 -0700 |
| commit | 697202b0b1c7c02208c620f96c608e0817d079dd (patch) | |
| tree | a3b7a86fcb6aa48d45876abfd600659361aa0b44 /builtin/am.c | |
| parent | builtin/maintenance: fix locking race with refs and reflogs tasks (diff) | |
| download | git-697202b0b1c7c02208c620f96c608e0817d079dd.tar.gz git-697202b0b1c7c02208c620f96c608e0817d079dd.zip | |
usage: allow dying without writing an error message
Sometimes code wants to die in a situation where it already has written
an error message. To use the same error code as `die()` we have to use
`exit(128)`, which is easy to get wrong and leaves magic numbers all
over our codebase.
Teach `die_message_builtin()` to not print any error when passed a
`NULL` pointer as error string. Like this, such users can now call
`die(NULL)` to achieve the same result without any hardcoded error
codes.
Adapt a couple of builtins to use this new pattern to demonstrate that
there is a need for such a helper.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/am.c')
| -rw-r--r-- | builtin/am.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/builtin/am.c b/builtin/am.c index e32a3b4c97..a800003340 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -1000,7 +1000,7 @@ static void am_setup(struct am_state *state, enum patch_format patch_format, if (!patch_format) { fprintf_ln(stderr, _("Patch format detection failed.")); - exit(128); + die(NULL); } if (mkdir(state->dir, 0777) < 0 && errno != EEXIST) @@ -1178,7 +1178,7 @@ static void NORETURN die_user_resolve(const struct am_state *state) strbuf_release(&sb); } - exit(128); + die(NULL); } /** |
