]> git.ipfire.org Git - thirdparty/git.git/blobdiff - rerere.c
send-email: sanitize_address use qq["foo"], not "\"foo\""
[thirdparty/git.git] / rerere.c
index 9dd4c7e1d3cd32829c3e7b464991dbb2eaabf2ff..861ca7c815b4857f1fde399617860e5a179e2ca3 100644 (file)
--- 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);
 }
@@ -358,14 +358,14 @@ 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 */
                }
        }
        return 0;
 }
 
-static int merge(const char *name, int renormalize, const char *path)
+static int merge(const char *name, const char *path)
 {
        int ret;
        mmfile_t cur = {NULL, 0}, base = {NULL, 0}, other = {NULL, 0};
@@ -380,10 +380,15 @@ static int merge(const char *name, int renormalize, const char *path)
                ret = 1;
                goto out;
        }
-       ret = ll_merge(&result, path, &base, NULL, &cur, "", &other, "",
-                       renormalize ? LL_OPT_RENORMALIZE : 0);
+       ret = ll_merge(&result, path, &base, NULL, &cur, "", &other, "", 0);
        if (!ret) {
-               FILE *f = fopen(path, "w");
+               FILE *f;
+
+               if (utime(rerere_path(name, "postimage"), NULL) < 0)
+                       warning("failed utime() on %s: %s",
+                                       rerere_path(name, "postimage"),
+                                       strerror(errno));
+               f = fopen(path, "w");
                if (!f)
                        return error("Could not open %s: %s", path,
                                     strerror(errno));
@@ -429,10 +434,10 @@ static int update_paths(struct string_list *update)
        return status;
 }
 
-static int do_plain_rerere(struct string_list *rr, int fd, int renormalize)
+static int do_plain_rerere(struct string_list *rr, int fd)
 {
-       struct string_list conflict = { NULL, 0, 0, 1 };
-       struct string_list update = { NULL, 0, 0, 1 };
+       struct string_list conflict = STRING_LIST_INIT_DUP;
+       struct string_list update = STRING_LIST_INIT_DUP;
        int i;
 
        find_conflict(&conflict);
@@ -454,7 +459,7 @@ static int do_plain_rerere(struct string_list *rr, int fd, int renormalize)
                        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"));
@@ -474,9 +479,9 @@ static int do_plain_rerere(struct string_list *rr, int fd, int renormalize)
                const char *name = (const char *)rr->items[i].util;
 
                if (has_rerere_resolution(name)) {
-                       if (!merge(name, renormalize, path)) {
+                       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
@@ -552,13 +557,13 @@ int setup_rerere(struct string_list *merge_rr, int flags)
 
 int rerere(int flags)
 {
-       struct string_list merge_rr = { NULL, 0, 0, 1 };
+       struct string_list merge_rr = STRING_LIST_INIT_DUP;
        int fd;
 
        fd = setup_rerere(&merge_rr, flags);
        if (fd < 0)
                return 0;
-       return do_plain_rerere(&merge_rr, fd, merge_renormalize);
+       return do_plain_rerere(&merge_rr, fd);
 }
 
 static int rerere_forget_one_path(const char *path, struct string_list *rr)
@@ -582,7 +587,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;
 }
@@ -590,8 +595,8 @@ static int rerere_forget_one_path(const char *path, struct string_list *rr)
 int rerere_forget(const char **pathspec)
 {
        int i, fd;
-       struct string_list conflict = { NULL, 0, 0, 1 };
-       struct string_list merge_rr = { NULL, 0, 0, 1 };
+       struct string_list conflict = STRING_LIST_INIT_DUP;
+       struct string_list merge_rr = STRING_LIST_INIT_DUP;
 
        if (read_cache() < 0)
                return error("Could not read index");