X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=rerere.c;h=a59f74f76c293efa783103eaf3d167c97b3768ea;hb=609eb9f7ff2af45d52ea90c0678a442d46aaa163;hp=a86d73d9dcb0d07283885825a16286b3c7990ea2;hpb=103209c6782586d92b04ee1fc71c0fd6f6385f5f;p=git.git diff --git a/rerere.c b/rerere.c index a86d73d9d..d03a69634 100644 --- a/rerere.c +++ b/rerere.c @@ -46,7 +46,7 @@ static void read_rr(struct string_list *rr) ; /* do nothing */ if (i == sizeof(buf)) die("filename too long"); - string_list_insert(buf, rr)->util = name; + string_list_insert(rr, buf)->util = name; } fclose(in); } @@ -153,7 +153,7 @@ static int handle_path(unsigned char *sha1, struct rerere_io *io, int marker_siz git_SHA_CTX ctx; int hunk_no = 0; enum { - RR_CONTEXT = 0, RR_SIDE_1, RR_SIDE_2, RR_ORIGINAL, + RR_CONTEXT = 0, RR_SIDE_1, RR_SIDE_2, RR_ORIGINAL } hunk = RR_CONTEXT; struct strbuf one = STRBUF_INIT, two = STRBUF_INIT; struct strbuf buf = STRBUF_INIT; @@ -319,13 +319,13 @@ static int handle_cache(const char *path, unsigned char *sha1, const char *outpu if (!mmfile[i].ptr && !mmfile[i].size) mmfile[i].ptr = xstrdup(""); } - ll_merge(&result, path, &mmfile[0], + ll_merge(&result, path, &mmfile[0], NULL, &mmfile[1], "ours", &mmfile[2], "theirs", 0); for (i = 0; i < 3; i++) free(mmfile[i].ptr); - memset(&io, 0, sizeof(&io)); + memset(&io, 0, sizeof(io)); io.io.getline = rerere_mem_getline; if (output) io.io.output = fopen(output, "w"); @@ -354,7 +354,7 @@ static int find_conflict(struct string_list *conflict) ce_same_name(e2, e3) && S_ISREG(e2->ce_mode) && S_ISREG(e3->ce_mode)) { - string_list_insert((const char *)e2->name, conflict); + string_list_insert(conflict, (const char *)e2->name); i++; /* skip over both #2 and #3 */ } } @@ -364,7 +364,7 @@ static int find_conflict(struct string_list *conflict) static int merge(const char *name, const char *path) { int ret; - mmfile_t cur, base, other; + mmfile_t cur = {NULL, 0}, base = {NULL, 0}, other = {NULL, 0}; mmbuffer_t result = {NULL, 0}; if (handle_file(path, NULL, rerere_path(name, "thisimage")) < 0) @@ -372,9 +372,11 @@ static int merge(const char *name, const char *path) if (read_mmfile(&cur, rerere_path(name, "thisimage")) || read_mmfile(&base, rerere_path(name, "preimage")) || - read_mmfile(&other, rerere_path(name, "postimage"))) - return 1; - ret = ll_merge(&result, path, &base, &cur, "", &other, "", 0); + read_mmfile(&other, rerere_path(name, "postimage"))) { + ret = 1; + goto out; + } + ret = ll_merge(&result, path, &base, NULL, &cur, "", &other, "", 0); if (!ret) { FILE *f = fopen(path, "w"); if (!f) @@ -387,6 +389,7 @@ static int merge(const char *name, const char *path) strerror(errno)); } +out: free(cur.ptr); free(base.ptr); free(other.ptr); @@ -446,7 +449,7 @@ static int do_plain_rerere(struct string_list *rr, int fd) if (ret < 1) continue; hex = xstrdup(sha1_to_hex(sha1)); - string_list_insert(path, rr)->util = hex; + string_list_insert(rr, path)->util = hex; if (mkdir(git_path("rr-cache/%s", hex), 0755)) continue; handle_file(path, NULL, rerere_path(hex, "preimage")); @@ -468,7 +471,7 @@ static int do_plain_rerere(struct string_list *rr, int fd) if (has_rerere_resolution(name)) { if (!merge(name, path)) { if (rerere_autoupdate) - string_list_insert(path, &update); + string_list_insert(&update, path); fprintf(stderr, "%s '%s' using previous resolution.\n", rerere_autoupdate @@ -574,7 +577,7 @@ static int rerere_forget_one_path(const char *path, struct string_list *rr) fprintf(stderr, "Updated preimage for '%s'\n", path); - string_list_insert(path, rr)->util = hex; + string_list_insert(rr, path)->util = hex; fprintf(stderr, "Forgot resolution for %s\n", path); return 0; }