aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2024-04-16 14:50:29 -0700
committerJunio C Hamano <gitster@pobox.com>2024-04-16 14:50:29 -0700
commita7589384d5a54f9c135c19bd8bc5b04715cc2865 (patch)
treeedb4ba27341bb7c4b92831509c9f71d27d433209
parent107313eb11931a66ec4cd3f83bd6c260f296ad19 (diff)
parentc63adab96184135718debdc8c7fc53a2abd80ca8 (diff)
downloadgit-a7589384d5a54f9c135c19bd8bc5b04715cc2865.tar.gz
Merge branch 'rs/usage-fallback-to-show-message-format'
vreportf(), which is usede by error() and friends, has been taught to give the error message printf-format string when its vsnprintf() call fails, instead of showing nothing useful to identify the nature of the error. * rs/usage-fallback-to-show-message-format: usage: report vsnprintf(3) failure
-rw-r--r--usage.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/usage.c b/usage.c
index 09f0ed509b..7a2f7805f5 100644
--- a/usage.c
+++ b/usage.c
@@ -19,8 +19,11 @@ static void vreportf(const char *prefix, const char *err, va_list params)
}
memcpy(msg, prefix, prefix_len);
p = msg + prefix_len;
- if (vsnprintf(p, pend - p, err, params) < 0)
+ if (vsnprintf(p, pend - p, err, params) < 0) {
+ fprintf(stderr, _("error: unable to format message: %s\n"),
+ err);
*p = '\0'; /* vsnprintf() failed, clip at prefix */
+ }
for (; p != pend - 1 && *p; p++) {
if (iscntrl(*p) && *p != '\t' && *p != '\n')