1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-12 22:16:13 +02:00

Merge branch 'rs/usage-fallback-to-show-message-format' into next

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
This commit is contained in:
Junio C Hamano 2024-04-10 10:09:15 -07:00
commit 9a34aed4d5

View File

@ -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')