Skip to content

Commit 6527925

Browse files
hanwengitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3474b60 commit 6527925

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

refs/debug.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,15 +284,18 @@ static int debug_print_reflog_ent(struct object_id *old_oid,
284284
int ret;
285285
char o[GIT_MAX_HEXSZ + 1] = "null";
286286
char n[GIT_MAX_HEXSZ + 1] = "null";
287+
char *msgend = strchrnul(msg, '\n');
287288
if (old_oid)
288289
oid_to_hex_r(o, old_oid);
289290
if (new_oid)
290291
oid_to_hex_r(n, new_oid);
291292

292293
ret = dbg->fn(old_oid, new_oid, committer, timestamp, tz, msg,
293294
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);
296299
return ret;
297300
}
298301

0 commit comments

Comments
 (0)