X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=rerere.c;h=f221bed1e97a0f1b41d1845edac270a109e3a4dd;hb=73d419558d9fa4de3be28bd58158636bc739808e;hp=d1d3e753955146cadfaf6da274487a4a369f0521;hpb=db3df36a3d2e222fa8469c16724a74192c5529a0;p=git.git diff --git a/rerere.c b/rerere.c index d1d3e7539..f221bed1e 100644 --- a/rerere.c +++ b/rerere.c @@ -319,7 +319,7 @@ 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++) @@ -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);