t6036: Test index and worktree state, not just that merge fails
[gitweb.git] / merge-recursive.c
index c5746988196b8139ca3234f8b30d03af56d33324..7db1538f1296d845b75f168c8de3a3030cf28172 100644 (file)
@@ -935,14 +935,7 @@ static int process_renames(struct merge_options *o,
 
                        try_merge = 0;
 
-                       if (string_list_has_string(&o->current_directory_set, ren1_dst)) {
-                               clean_merge = 0;
-                               output(o, 1, "CONFLICT (rename/directory): Rename %s->%s in %s "
-                                      " directory %s added in %s",
-                                      ren1_src, ren1_dst, branch1,
-                                      ren1_dst, branch2);
-                               conflict_rename_dir(o, ren1, branch1);
-                       } else if (sha_eq(src_other.sha1, null_sha1)) {
+                       if (sha_eq(src_other.sha1, null_sha1)) {
                                clean_merge = 0;
                                output(o, 1, "CONFLICT (rename/delete): Rename %s->%s in %s "
                                       "and deleted in %s",
@@ -1040,6 +1033,13 @@ static int process_renames(struct merge_options *o,
                                        if (!ren1->dst_entry->stages[2].mode !=
                                            !ren1->dst_entry->stages[3].mode)
                                                ren1->dst_entry->processed = 0;
+                               } else if (string_list_has_string(&o->current_directory_set, ren1_dst)) {
+                                       clean_merge = 0;
+                                       output(o, 1, "CONFLICT (rename/directory): Rename %s->%s in %s "
+                                              " directory %s added in %s",
+                                              ren1_src, ren1_dst, branch1,
+                                              ren1_dst, branch2);
+                                       conflict_rename_dir(o, ren1, branch1);
                                } else {
                                        if (mfi.merge || !mfi.clean)
                                                output(o, 1, "Renaming %s => %s", ren1_src, ren1_dst);
@@ -1259,9 +1259,8 @@ static int process_df_entry(struct merge_options *o,
        const char *conf;
        struct stat st;
 
-       /* We currently only handle D->F cases */
-       assert((!o_sha && a_sha && !b_sha) ||
-              (!o_sha && !a_sha && b_sha));
+       if (!((!o_sha && a_sha && !b_sha) || (!o_sha && !a_sha && b_sha)))
+               return 1; /* we don't handle non D-F cases */
 
        entry->processed = 1;
 
@@ -1350,6 +1349,12 @@ int merge_trees(struct merge_options *o,
                                && !process_df_entry(o, path, e))
                                clean = 0;
                }
+               for (i = 0; i < entries->nr; i++) {
+                       struct stage_data *e = entries->items[i].util;
+                       if (!e->processed)
+                               die("Unprocessed path??? %s",
+                                   entries->items[i].string);
+               }
 
                string_list_clear(re_merge, 0);
                string_list_clear(re_head, 0);