]> git.ipfire.org Git - thirdparty/git.git/commitdiff
refs/debug: trim trailing LF from reflog message
authorHan-Wen Nienhuys <hanwen@google.com>
Thu, 2 Dec 2021 17:36:33 +0000 (17:36 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 2 Dec 2021 19:14:08 +0000 (11:14 -0800)
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>
refs/debug.c

index 8667c64023784051169451517d55f4055e3919aa..2defaa9c52e88863271c8966a86d1809e0cd422a 100644 (file)
@@ -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;
 }