Code

print warning/error/fatal messages in one shot
authorNicolas Pitre <nico@cam.org>
Fri, 9 Nov 2007 19:33:54 +0000 (14:33 -0500)
committerJunio C Hamano <gitster@pobox.com>
Sat, 10 Nov 2007 06:25:36 +0000 (22:25 -0800)
Not doing so is likely to create a messed up display when sent over the
sideband protocol.

Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
usage.c

diff --git a/usage.c b/usage.c
index f5e652cc76d7587fd7b682eb865d3436c99b16fb..a5fc4ec5fae66823266862fa0254474696c220e6 100644 (file)
--- a/usage.c
+++ b/usage.c
@@ -7,9 +7,9 @@
 
 static void report(const char *prefix, const char *err, va_list params)
 {
-       fputs(prefix, stderr);
-       vfprintf(stderr, err, params);
-       fputs("\n", stderr);
+       char msg[256];
+       vsnprintf(msg, sizeof(msg), err, params);
+       fprintf(stderr, "%s%s\n", prefix, msg);
 }
 
 static NORETURN void usage_builtin(const char *err)