merge-ort: collect which directories are removed in dirs_removed

Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Elijah Newren committed Jan 7, 2021 at 21:35 UTC eb3e3e1ddffa1348532a6b8d741c235e4c73017c
1 file changed +27
merge-ort.c
+27
@@ -480,6 +480,27 @@ static void setup_path_info(struct merge_options *opt,
480 result->util = mi;
481 }
482
483 +static void collect_rename_info(struct merge_options *opt,
484 + struct name_entry *names,
485 + const char *dirname,
486 + const char *fullname,
487 + unsigned filemask,
488 + unsigned dirmask,
489 + unsigned match_mask)
490 +{
491 + struct rename_info *renames = &opt->priv->renames;
492 +
493 + /* Update dirs_removed, as needed */
494 + if (dirmask == 1 || dirmask == 3 || dirmask == 5) {
495 + /* absent_mask = 0x07 - dirmask; sides = absent_mask/2 */
496 + unsigned sides = (0x07 - dirmask)/2;
497 + if (sides & 1)
498 + strset_add(&renames->dirs_removed[1], fullname);
499 + if (sides & 2)
500 + strset_add(&renames->dirs_removed[2], fullname);
501 + }
502 +}
503 +
504 static int collect_merge_info_callback(int n,
505 unsigned long mask,
506 unsigned long dirmask,
@@ -580,6 +601,12 @@ static int collect_merge_info_callback(int n,
601 return mask;
602 }
603
604 + /*
605 + * Gather additional information used in rename detection.
606 + */
607 + collect_rename_info(opt, names, dirname, fullpath,
608 + filemask, dirmask, match_mask);
609 +
610 /*
611 * Record information about the path so we can resolve later in
612 * process_entries.