]> git.ipfire.org Git - thirdparty/git.git/commitdiff
refs: move the logic to add \t to reflog to the files backend
authorHan-Wen Nienhuys <hanwen@google.com>
Fri, 31 Jul 2020 11:36:10 +0000 (11:36 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 31 Jul 2020 17:21:51 +0000 (10:21 -0700)
523fa69c (reflog: cleanse messages in the refs.c layer, 2020-07-10)
centralized reflog normalizaton.  However, the normalizaton added a
leading "\t" to the message. This is an artifact of the reflog
storage format in the files backend, so it should be added there.

Routines that parse back the reflog (such as grab_nth_branch_switch)
expect the "\t" to not be in the message, so without this fix, git
with reftable cannot process the "@{-1}" syntax.

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs.c
refs/files-backend.c

diff --git a/refs.c b/refs.c
index b1dc81640b159d2c000ea28f52283379b7d06216..9d58e17eaf7b1b5fb983bf15320a3ed7d0bce67c 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -875,7 +875,6 @@ static void copy_reflog_msg(struct strbuf *sb, const char *msg)
        char c;
        int wasspace = 1;
 
-       strbuf_addch(sb, '\t');
        while ((c = *msg++)) {
                if (wasspace && isspace(c))
                        continue;
index e0aba23eb29529a63c61fd8f44118fadbe7e5522..985631f33edf92afc706061b0d208bd35fab4bdc 100644 (file)
@@ -1628,8 +1628,10 @@ static int log_ref_write_fd(int fd, const struct object_id *old_oid,
        int ret = 0;
 
        strbuf_addf(&sb, "%s %s %s", oid_to_hex(old_oid), oid_to_hex(new_oid), committer);
-       if (msg && *msg)
+       if (msg && *msg) {
+               strbuf_addch(&sb, '\t');
                strbuf_addstr(&sb, msg);
+       }
        strbuf_addch(&sb, '\n');
        if (write_in_full(fd, sb.buf, sb.len) < 0)
                ret = -1;