@matheusbsbs / matheus-bagliano / commits / 25429fed5c
Fork 0

refs: move the logic to add \t to reflog to the files backend

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>

Han-Wen Nienhuys committed Jul 31, 2020 at 11:36 UTC 25429fed5ce134bce9f729d927ac397badae1959
2 files changed +3 -2
refs.c
-1
@@ -875,7 +875,6 @@ static void copy_reflog_msg(struct strbuf *sb, const char *msg)
875 char c;
876 int wasspace = 1;
877
878 - strbuf_addch(sb, '\t');
878 while ((c = *msg++)) {
879 if (wasspace && isspace(c))
880 continue;
refs/files-backend.c
+3 -1
@@ -1628,8 +1628,10 @@ static int log_ref_write_fd(int fd, const struct object_id *old_oid,
1628 int ret = 0;
1629
1630 strbuf_addf(&sb, "%s %s %s", oid_to_hex(old_oid), oid_to_hex(new_oid), committer);
1631 - if (msg && *msg)
1631 + if (msg && *msg) {
1632 + strbuf_addch(&sb, '\t');
1633 strbuf_addstr(&sb, msg);
1634 + }
1635 strbuf_addch(&sb, '\n');
1636 if (write_in_full(fd, sb.buf, sb.len) < 0)
1637 ret = -1;