summaryrefslogtreecommitdiff
path: root/builtin/fast-import.c
diff options
context:
space:
mode:
authorLibravatar Ævar Arnfjörð Bjarmason <avarab@gmail.com>2021-12-07 19:26:30 +0100
committerLibravatar Junio C Hamano <gitster@pobox.com>2021-12-07 13:25:15 -0800
commite081a7c3b7290c50c817598e5f2686d068540762 (patch)
treee1b23b79d8067b0d4fe4629c5bc8d8d787958aa2 /builtin/fast-import.c
parentusage.c: add a die_message() routine (diff)
downloadtgif-e081a7c3b7290c50c817598e5f2686d068540762.tar.xz
usage.c API users: use die_message() for "fatal :" + exit 128
Change code that printed its own "fatal: " message and exited with a status code of 128 to use the die_message() function added in a preceding commit. This change also demonstrates why the return value of die_message_routine() needed to be that of "report_fn". We have callers such as the run-command.c::child_err_spew() which would like to replace its error routine with the return value of "get_die_message_routine()". Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/fast-import.c')
-rw-r--r--builtin/fast-import.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/builtin/fast-import.c b/builtin/fast-import.c
index 20406f6775..2b2e28bad7 100644
--- a/builtin/fast-import.c
+++ b/builtin/fast-import.c
@@ -401,16 +401,18 @@ static void dump_marks(void);
static NORETURN void die_nicely(const char *err, va_list params)
{
+ va_list cp;
static int zombie;
- char message[2 * PATH_MAX];
+ report_fn die_message_fn = get_die_message_routine();
- vsnprintf(message, sizeof(message), err, params);
- fputs("fatal: ", stderr);
- fputs(message, stderr);
- fputc('\n', stderr);
+ va_copy(cp, params);
+ die_message_fn(err, params);
if (!zombie) {
+ char message[2 * PATH_MAX];
+
zombie = 1;
+ vsnprintf(message, sizeof(message), err, cp);
write_crash_report(message);
end_packfile();
unkeep_all_packs();