refs/debug: trim trailing LF from reflog message

On iteration, the reflog message is always terminated by a newline. Trim it to avoid clobbering the console with is this extra newline. Signed-off-by: Han-Wen Nienhuys <hanwen@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Han-Wen Nienhuys committed Dec 2, 2021 at 17:36 UTC 65279256f3d3576ff16332d7f0ee124f593cb476
1 file changed +5 -2
refs/debug.c
+5 -2
@@ -284,6 +284,7 @@ static int debug_print_reflog_ent(struct object_id *old_oid,
284 int ret;
285 char o[GIT_MAX_HEXSZ + 1] = "null";
286 char n[GIT_MAX_HEXSZ + 1] = "null";
287 + char *msgend = strchrnul(msg, '\n');
288 if (old_oid)
289 oid_to_hex_r(o, old_oid);
290 if (new_oid)
@@ -291,8 +292,10 @@ static int debug_print_reflog_ent(struct object_id *old_oid,
292
293 ret = dbg->fn(old_oid, new_oid, committer, timestamp, tz, msg,
294 dbg->cb_data);
294 - trace_printf_key(&trace_refs, "reflog_ent %s (ret %d): %s -> %s, %s %ld \"%s\"\n",
295 - dbg->refname, ret, o, n, committer, (long int)timestamp, msg);
295 + trace_printf_key(&trace_refs,
296 + "reflog_ent %s (ret %d): %s -> %s, %s %ld \"%.*s\"\n",
297 + dbg->refname, ret, o, n, committer,
298 + (long int)timestamp, (int)(msgend - msg), msg);
299 return ret;
300 }
301