aboutsummaryrefslogtreecommitdiffstats
path: root/refs
diff options
context:
space:
mode:
authorHan-Wen Nienhuys <hanwen@google.com>2021-12-02 17:36:33 +0000
committerJunio C Hamano <gitster@pobox.com>2021-12-02 11:14:08 -0800
commit65279256f3d3576ff16332d7f0ee124f593cb476 (patch)
tree73e2cdd1ac57642b869fb9a75649246a2f6c05ae /refs
parent3474b602a5387df459a25c3e35747c11f1b08da7 (diff)
downloadgit-65279256f3d3576ff16332d7f0ee124f593cb476.tar.gz
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>
Diffstat (limited to 'refs')
-rw-r--r--refs/debug.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/refs/debug.c b/refs/debug.c
index 8667c64023..2defaa9c52 100644
--- a/refs/debug.c
+++ b/refs/debug.c
@@ -284,6 +284,7 @@ static int debug_print_reflog_ent(struct object_id *old_oid,
int ret;
char o[GIT_MAX_HEXSZ + 1] = "null";
char n[GIT_MAX_HEXSZ + 1] = "null";
+ char *msgend = strchrnul(msg, '\n');
if (old_oid)
oid_to_hex_r(o, old_oid);
if (new_oid)
@@ -291,8 +292,10 @@ static int debug_print_reflog_ent(struct object_id *old_oid,
ret = dbg->fn(old_oid, new_oid, committer, timestamp, tz, msg,
dbg->cb_data);
- trace_printf_key(&trace_refs, "reflog_ent %s (ret %d): %s -> %s, %s %ld \"%s\"\n",
- dbg->refname, ret, o, n, committer, (long int)timestamp, msg);
+ trace_printf_key(&trace_refs,
+ "reflog_ent %s (ret %d): %s -> %s, %s %ld \"%.*s\"\n",
+ dbg->refname, ret, o, n, committer,
+ (long int)timestamp, (int)(msgend - msg), msg);
return ret;
}