coccicheck: use --all-includes by default
[gitweb.git] / rerere.c
index 1810c040daba6398580bd9a40179b365887a91a6..5d083ca572df0c8a2cb90c0b12c14e15b4134d48 100644 (file)
--- a/rerere.c
+++ b/rerere.c
@@ -980,7 +980,8 @@ static int handle_cache(const char *path, unsigned char *sha1, const char *outpu
                        break;
                i = ce_stage(ce) - 1;
                if (!mmfile[i].ptr) {
-                       mmfile[i].ptr = read_sha1_file(ce->sha1, &type, &size);
+                       mmfile[i].ptr = read_sha1_file(ce->oid.hash, &type,
+                                                      &size);
                        mmfile[i].size = size;
                }
        }
@@ -1050,8 +1051,8 @@ static int rerere_forget_one_path(const char *path, struct string_list *rr)
                handle_cache(path, sha1, rerere_path(id, "thisimage"));
                if (read_mmfile(&cur, rerere_path(id, "thisimage"))) {
                        free(cur.ptr);
-                       return error("Failed to update conflicted state in '%s'",
-                                    path);
+                       error("Failed to update conflicted state in '%s'", path);
+                       goto fail_exit;
                }
                cleanly_resolved = !try_merge(id, path, &cur, &result);
                free(result.ptr);
@@ -1060,14 +1061,19 @@ static int rerere_forget_one_path(const char *path, struct string_list *rr)
                        break;
        }
 
-       if (id->collection->status_nr <= id->variant)
-               return error("no remembered resolution for '%s'", path);
+       if (id->collection->status_nr <= id->variant) {
+               error("no remembered resolution for '%s'", path);
+               goto fail_exit;
+       }
 
        filename = rerere_path(id, "postimage");
-       if (unlink(filename))
-               return (errno == ENOENT
-                       ? error("no remembered resolution for %s", path)
-                       : error_errno("cannot unlink %s", filename));
+       if (unlink(filename)) {
+               if (errno == ENOENT)
+                       error("no remembered resolution for %s", path);
+               else
+                       error_errno("cannot unlink %s", filename);
+               goto fail_exit;
+       }
 
        /*
         * Update the preimage so that the user can resolve the
@@ -1086,6 +1092,10 @@ static int rerere_forget_one_path(const char *path, struct string_list *rr)
        item->util = id;
        fprintf(stderr, "Forgot resolution for %s\n", path);
        return 0;
+
+fail_exit:
+       free(id);
+       return -1;
 }
 
 int rerere_forget(struct pathspec *pathspec)