rerere: fix crash with files rerere can't handle
[gitweb.git] / rerere.c
index da1ab54027261bfb929af4154d653453b3c0fbad..895ad80c0cf910f37787a7e3988a158cc6a6dad4 100644 (file)
--- a/rerere.c
+++ b/rerere.c
@@ -823,10 +823,7 @@ static int do_plain_rerere(struct string_list *rr, int fd)
                struct rerere_id *id;
                unsigned char sha1[20];
                const char *path = conflict.items[i].string;
-               int ret;
-
-               if (string_list_has_string(rr, path))
-                       continue;
+               int ret, has_string;
 
                /*
                 * Ask handle_file() to scan and assign a
@@ -834,7 +831,12 @@ static int do_plain_rerere(struct string_list *rr, int fd)
                 * yet.
                 */
                ret = handle_file(path, sha1, NULL);
-               if (ret < 1)
+               has_string = string_list_has_string(rr, path);
+               if (ret < 0 && has_string) {
+                       remove_variant(string_list_lookup(rr, path)->util);
+                       string_list_remove(rr, path, 1);
+               }
+               if (ret < 1 || has_string)
                        continue;
 
                id = new_rerere_id(sha1);