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 <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Elijah Newren committed Jan 1, 2021 at 02:34 UTC 0ccfa4e5d8489abe7c5d3fe29b68e4fe0cae6fe1
1 file changed +22 -1
merge-ort.c
+22 -1
@@ -976,7 +976,28 @@ static void process_entry(struct merge_options *opt,
976 assert(ci->df_conflict);
977 }
978
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) {
1001 die("Not yet implemented.");
1002 }
1003