Skip to content

Commit 2adc7dc

Browse files
newrengitster
authored andcommitted
conflict_rename_rename_1to2(): Fix checks for presence of D/F conflicts
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a0de2f6 commit 2adc7dc

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

merge-recursive.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -841,17 +841,16 @@ static void conflict_rename_rename_1to2(struct merge_options *o,
841841
const char *ren2_dst = pair2->two->path;
842842
const char *dst_name1 = ren1_dst;
843843
const char *dst_name2 = ren2_dst;
844-
if (string_list_has_string(&o->current_directory_set, ren1_dst)) {
844+
struct stat st;
845+
if (lstat(ren1_dst, &st) == 0 && S_ISDIR(st.st_mode)) {
845846
dst_name1 = del[delp++] = unique_path(o, ren1_dst, branch1);
846847
output(o, 1, "%s is a directory in %s adding as %s instead",
847848
ren1_dst, branch2, dst_name1);
848-
remove_file(o, 0, ren1_dst, 0);
849849
}
850-
if (string_list_has_string(&o->current_directory_set, ren2_dst)) {
850+
if (lstat(ren2_dst, &st) == 0 && S_ISDIR(st.st_mode)) {
851851
dst_name2 = del[delp++] = unique_path(o, ren2_dst, branch2);
852852
output(o, 1, "%s is a directory in %s adding as %s instead",
853853
ren2_dst, branch1, dst_name2);
854-
remove_file(o, 0, ren2_dst, 0);
855854
}
856855
if (o->call_depth) {
857856
remove_file_from_cache(dst_name1);

t/t6022-merge-rename.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ test_expect_success 'setup rename one file to two; directories moving out of the
692692
git commit -m "Rename to two"
693693
'
694694

695-
test_expect_failure 'check handling of differently renamed file with D/F conflicts' '
695+
test_expect_success 'check handling of differently renamed file with D/F conflicts' '
696696
git checkout -q first-rename-redo^0 &&
697697
test_must_fail git merge --strategy=recursive second-rename-redo &&
698698

0 commit comments

Comments
 (0)