summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Hostetler <jeffhost@microsoft.com>2019-08-08 14:19:02 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-08-08 17:39:44 (GMT)
commitad43e37839ea6a3cf369af074a723a60cd66233b (patch)
treeb42f4e782a8dfa8ca00a8a7eb755263250c0a44b
parent04f10d332f47aed7d93ff3ed5c2bb3a366e44693 (diff)
downloadgit-ad43e37839ea6a3cf369af074a723a60cd66233b.zip
git-ad43e37839ea6a3cf369af074a723a60cd66233b.tar.gz
git-ad43e37839ea6a3cf369af074a723a60cd66233b.tar.bz2
trace2: trim trailing whitespace in normal format error message
Avoid creating unnecessary trailing whitespace in normal target format error messages when the message is omitted. Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--trace2/tr2_tgt_normal.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/trace2/tr2_tgt_normal.c b/trace2/tr2_tgt_normal.c
index 47a1882..213724d 100644
--- a/trace2/tr2_tgt_normal.c
+++ b/trace2/tr2_tgt_normal.c
@@ -142,8 +142,11 @@ static void fn_error_va_fl(const char *file, int line, const char *fmt,
{
struct strbuf buf_payload = STRBUF_INIT;
- strbuf_addstr(&buf_payload, "error ");
- maybe_append_string_va(&buf_payload, fmt, ap);
+ strbuf_addstr(&buf_payload, "error");
+ if (fmt && *fmt) {
+ strbuf_addch(&buf_payload, ' ');
+ maybe_append_string_va(&buf_payload, fmt, ap);
+ }
normal_io_write_fl(file, line, &buf_payload);
strbuf_release(&buf_payload);
}