conflict_rename_delete(): Check whether D/F conflicts are still present
If all the paths below some directory involved in a D/F conflict were not removed during the rest of the merge, then the contents of the file whose path conflicted needs to be recorded in file with an alternative filename. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Elijah Newren committed
Sep 20, 2010 at 02:29 UTC
a0de2f6bd3b79f7ab61ea90f795b964a7f7f3d6d
2 files changed
+10
-2
merge-recursive.c
+8
@@ -807,6 +807,8 @@ static void conflict_rename_delete(struct merge_options *o,
807
const char *other_branch)
808
{
809
char *dest_name = pair->two->path;
810
+ int df_conflict = 0;
811
+ struct stat st;
812
813
output(o, 1, "CONFLICT (rename/delete): Rename %s->%s in %s "
814
"and deleted in %s",
@@ -817,7 +819,13 @@ static void conflict_rename_delete(struct merge_options *o,
819
rename_branch == o->branch1 ? pair->two : NULL,
820
rename_branch == o->branch1 ? NULL : pair->two,
821
1);
822
+ if (lstat(dest_name, &st) == 0 && S_ISDIR(st.st_mode)) {
823
+ dest_name = unique_path(o, dest_name, rename_branch);
824
+ df_conflict = 1;
825
+ }
826
update_file(o, 0, pair->two->sha1, pair->two->mode, dest_name);
827
+ if (df_conflict)
828
+ free(dest_name);
829
}
830
831
static void conflict_rename_rename_1to2(struct merge_options *o,
t/t6022-merge-rename.sh
+2
-2
@@ -549,7 +549,7 @@ test_expect_success 'setup both rename source and destination involved in D/F co
549
git commit -m "Conflicts in the way"
550
'
551
552
-test_expect_failure 'both rename source and destination involved in D/F conflict' '
552
+test_expect_success 'both rename source and destination involved in D/F conflict' '
553
git reset --hard &&
554
rm -rf dir~* &&
555
git checkout -q rename-dest^0 &&
@@ -589,7 +589,7 @@ test_expect_success 'setup pair rename to parent of other (D/F conflicts)' '
589
git commit -m "Rename one/file -> two"
590
'
591
592
-test_expect_failure 'pair rename to parent of other (D/F conflicts) w/ untracked dir' '
592
+test_expect_success 'pair rename to parent of other (D/F conflicts) w/ untracked dir' '
593
git checkout -q rename-one^0 &&
594
mkdir one &&
595
test_must_fail git merge --strategy=recursive rename-two &&