Re: [PATCH v3 3/6] usage.c + gc: add and use a die_message_errno()
From: Junio C Hamano <hidden>
Date: 2021-10-24 06:01:00
Ævar Arnfjörð Bjarmason [off-list ref] writes:
Change code the "error: " output when we exit with 128 due to gc.log errors to use a "fatal: " prefix instead. This adds a sibling function to the die_errno() added in a preceding commit. Since it returns 128 instead of -1 we'll need to adjust report_last_gc_error(). Let's adjust it while we're at it to not conflate the "should skip" and "exit with this non-zero code" conditions, as the caller is no longer hardcoding "128", but relying on die_errno() to return a nen-zero exit() status.
OK, that sort of makes sense, and I am very glad that you didn't add die_message_errno() to [1/6]. Adding this function to support the caller that will benefit by using it in this same commit makes quite a lot of sense.
quoted hunk
diff --git a/usage.c b/usage.c index 3d4b90bce1f..efc2064dde3 100644 --- a/usage.c +++ b/usage.c@@ -233,6 +233,18 @@ void NORETURN die_errno(const char *fmt, ...) va_end(params); } +#undef die_message_errno +int die_message_errno(const char *fmt, ...) +{ + char buf[1024]; + va_list params; + + va_start(params, fmt); + die_message_routine(fmt_with_err(buf, sizeof(buf), fmt), params); + va_end(params); + return -1; +} + #undef error_errno int error_errno(const char *fmt, ...) {