Skip to content

Commit 0ccfa4e

Browse files
newrengitster
authored andcommitted
merge-ort: handle D/F conflict where directory disappears due to merge
When one side has a directory at a given path and the other side of history has a file at the path, but the merge resolves the directory away (e.g. because no path within that directory was modified and the other side deleted it, or because renaming moved all the files elsewhere), then we don't actually have a conflict anymore. We just need to clear away any information related to the relevant directory, and then the subsequent process_entry() handling can handle the given path. Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c5a6f65 commit 0ccfa4e

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

merge-ort.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,28 @@ static void process_entry(struct merge_options *opt,
976976
assert(ci->df_conflict);
977977
}
978978

979-
if (ci->df_conflict) {
979+
if (ci->df_conflict && ci->merged.result.mode == 0) {
980+
int i;
981+
982+
/*
983+
* directory no longer in the way, but we do have a file we
984+
* need to place here so we need to clean away the "directory
985+
* merges to nothing" result.
986+
*/
987+
ci->df_conflict = 0;
988+
assert(ci->filemask != 0);
989+
ci->merged.clean = 0;
990+
ci->merged.is_null = 0;
991+
/* and we want to zero out any directory-related entries */
992+
ci->match_mask = (ci->match_mask & ~ci->dirmask);
993+
ci->dirmask = 0;
994+
for (i = MERGE_BASE; i <= MERGE_SIDE2; i++) {
995+
if (ci->filemask & (1 << i))
996+
continue;
997+
ci->stages[i].mode = 0;
998+
oidcpy(&ci->stages[i].oid, &null_oid);
999+
}
1000+
} else if (ci->df_conflict && ci->merged.result.mode != 0) {
9801001
die("Not yet implemented.");
9811002
}
9821003

0 commit comments

Comments
 (0)