diff options
author | Junio C Hamano <gitster@pobox.com> | 2015-06-28 16:28:00 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-07-24 15:08:27 -0700 |
commit | e2cb6a950b4617edc3d07b372063b624b2b5c420 (patch) | |
tree | ee3c18e567dfbc38c523139ab292225318e1a314 /rerere.c | |
parent | f5800f6ad8b8cbf41a252f7ca0ae465217174c60 (diff) | |
download | git-e2cb6a950b4617edc3d07b372063b624b2b5c420.tar.gz |
rerere: write out each record of MERGE_RR in one go
Instead of writing the hash for a conflict, a HT, and the path
with three separate write_in_full() calls, format them into a
single record into a strbuf and write it out in one go.
As a more recent "rerere remaining" codepath abuses the .util field
of the merge_rr data to store a sentinel token, make sure that
codepath does not call into this function (of course, "remaining" is
a read-only operation and currently does not call it).
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'rerere.c')
-rw-r--r-- | rerere.c | 16 |
1 files changed, 9 insertions, 7 deletions
@@ -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"); |