]> git.ipfire.org Git - thirdparty/git.git/blobdiff - rerere.c
rerere: write out each record of MERGE_RR in one go
[thirdparty/git.git] / rerere.c
index 576361fb001e16e51f20cabd9900b56d03283acd..d8518a450f3de98d5fec5764e8d531c6253d1343 100644 (file)
--- a/rerere.c
+++ b/rerere.c
@@ -65,16 +65,18 @@ static int write_rr(struct string_list *rr, int out_fd)
 {
        int i;
        for (i = 0; i < rr->nr; i++) {
-               const char *path;
-               int length;
+               struct strbuf buf = STRBUF_INIT;
+
+               assert(rr->items[i].util != RERERE_RESOLVED);
                if (!rr->items[i].util)
                        continue;
-               path = rr->items[i].string;
-               length = strlen(path) + 1;
-               if (write_in_full(out_fd, rr->items[i].util, 40) != 40 ||
-                   write_str_in_full(out_fd, "\t") != 1 ||
-                   write_in_full(out_fd, path, length) != length)
+               strbuf_addf(&buf, "%s\t%s%c",
+                           (char *)rr->items[i].util,
+                           rr->items[i].string, 0);
+               if (write_in_full(out_fd, buf.buf, buf.len) != buf.len)
                        die("unable to write rerere record");
+
+               strbuf_release(&buf);
        }
        if (commit_lock_file(&write_lock) != 0)
                die("unable to write rerere record");