rerere: handle conflicts with multiple stage #1 entries
[gitweb.git] / rerere.c
index 1b0555f1a5a0233e931b13a088c052a56aef3977..b453a80085a016a08417111b60bd847ea2b3c742 100644 (file)
--- a/rerere.c
+++ b/rerere.c
@@ -369,10 +369,8 @@ static int check_one_conflict(int i, int *type)
        }
 
        *type = PUNTED;
-       if (ce_stage(e) == 1) {
-               if (active_nr <= ++i)
-                       return i + 1;
-       }
+       while (ce_stage(active_cache[i]) == 1)
+               i++;
 
        /* Only handle regular files with both stages #2 and #3 */
        if (i + 1 < active_nr) {
@@ -477,27 +475,23 @@ static int merge(const char *name, const char *path)
 
 static struct lock_file index_lock;
 
-static int update_paths(struct string_list *update)
+static void update_paths(struct string_list *update)
 {
        int i;
-       int fd = hold_locked_index(&index_lock, 0);
-       int status = 0;
 
-       if (fd < 0)
-               return -1;
+       hold_locked_index(&index_lock, 1);
 
        for (i = 0; i < update->nr; i++) {
                struct string_list_item *item = &update->items[i];
-               if (add_file_to_cache(item->string, ADD_CACHE_IGNORE_ERRORS))
-                       status = -1;
+               if (add_file_to_cache(item->string, 0))
+                       exit(128);
        }
 
-       if (!status && active_cache_changed) {
+       if (active_cache_changed) {
                if (write_locked_index(&the_index, &index_lock, COMMIT_LOCK))
                        die("Unable to write new index file");
-       } else if (fd >= 0)
+       } else
                rollback_lock_file(&index_lock);
-       return status;
 }
 
 static int do_plain_rerere(struct string_list *rr, int fd)