Code

conflict_rename_rename_1to2(): Fix checks for presence of D/F conflicts
authorElijah Newren <newren@gmail.com>
Mon, 20 Sep 2010 08:29:06 +0000 (02:29 -0600)
committerJunio C Hamano <gitster@pobox.com>
Thu, 30 Sep 2010 00:37:05 +0000 (17:37 -0700)
This function is called from process_df_entry(), near the end of the merge.
Rather than just checking whether one of the sides of the merge had a
directory at the same path as one of our files, check whether that
directory is still present by this point of our merge.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
merge-recursive.c
t/t6022-merge-rename.sh

index 09ce327c1706c2d2f04e7154da737257918aa554..85d69eb5677c04635c7518cb0978cf3664e7dd96 100644 (file)
@@ -841,17 +841,16 @@ static void conflict_rename_rename_1to2(struct merge_options *o,
        const char *ren2_dst = pair2->two->path;
        const char *dst_name1 = ren1_dst;
        const char *dst_name2 = ren2_dst;
-       if (string_list_has_string(&o->current_directory_set, ren1_dst)) {
+       struct stat st;
+       if (lstat(ren1_dst, &st) == 0 && S_ISDIR(st.st_mode)) {
                dst_name1 = del[delp++] = unique_path(o, ren1_dst, branch1);
                output(o, 1, "%s is a directory in %s adding as %s instead",
                       ren1_dst, branch2, dst_name1);
-               remove_file(o, 0, ren1_dst, 0);
        }
-       if (string_list_has_string(&o->current_directory_set, ren2_dst)) {
+       if (lstat(ren2_dst, &st) == 0 && S_ISDIR(st.st_mode)) {
                dst_name2 = del[delp++] = unique_path(o, ren2_dst, branch2);
                output(o, 1, "%s is a directory in %s adding as %s instead",
                       ren2_dst, branch1, dst_name2);
-               remove_file(o, 0, ren2_dst, 0);
        }
        if (o->call_depth) {
                remove_file_from_cache(dst_name1);
index 9bf190e03f55fa1cf4b771a4c9adfcdef2e875d7..0b6700242ce7faeb68ab0c6a1facf6460fb48634 100755 (executable)
@@ -692,7 +692,7 @@ test_expect_success 'setup rename one file to two; directories moving out of the
        git commit -m "Rename to two"
 '
 
-test_expect_failure 'check handling of differently renamed file with D/F conflicts' '
+test_expect_success 'check handling of differently renamed file with D/F conflicts' '
        git checkout -q first-rename-redo^0 &&
        test_must_fail git merge --strategy=recursive second-rename-redo &&