Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElijah Newren <newren@gmail.com>2021-01-19 22:53:44 +0300
committerJunio C Hamano <gitster@pobox.com>2021-01-21 09:18:55 +0300
commit98d0d08128200e244a83d917b63567c30547c36d (patch)
treea00c3bfff604debb6036b09719f22096dd1e5a27 /merge-ort.c
parent2f620a4f1983efcb70dee55917240b08065f2c4e (diff)
merge-ort: implement handle_directory_level_conflicts()
This is modelled on the version of handle_directory_level_conflicts() from merge-recursive.c, but is massively simplified due to the following factors: * strmap API provides simplifications over using direct hashmap * we have a dirs_removed field in struct rename_info that we have an easy way to populate from collect_merge_info(); this was already used in compute_rename_counts() and thus we do not need to check for condition #2. * The removal of condition #2 by handling it earlier in the code also obviates the need to check for condition #3 -- if both sides renamed a directory, meaning that the directory no longer exists on either side, then neither side could have added any new files to that directory, and thus there are no files whose locations we need to move due to such a directory rename. In fact, the same logic that makes condition #3 irrelevant means condition #1 is also irrelevant so we could drop this function. However, it is cheap to check if both sides rename the same directory, and doing so can save future computation. So, simply remove any directories that both sides renamed from the list of directory renames. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'merge-ort.c')
-rw-r--r--merge-ort.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/merge-ort.c b/merge-ort.c
index 8aa415c542..6dea4206dc 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -939,7 +939,24 @@ static void get_provisional_directory_renames(struct merge_options *opt,
static void handle_directory_level_conflicts(struct merge_options *opt)
{
- die("Not yet implemented!");
+ struct hashmap_iter iter;
+ struct strmap_entry *entry;
+ struct string_list duplicated = STRING_LIST_INIT_NODUP;
+ struct rename_info *renames = &opt->priv->renames;
+ struct strmap *side1_dir_renames = &renames->dir_renames[MERGE_SIDE1];
+ struct strmap *side2_dir_renames = &renames->dir_renames[MERGE_SIDE2];
+ int i;
+
+ strmap_for_each_entry(side1_dir_renames, &iter, entry) {
+ if (strmap_contains(side2_dir_renames, entry->key))
+ string_list_append(&duplicated, entry->key);
+ }
+
+ for (i = 0; i < duplicated.nr; i++) {
+ strmap_remove(side1_dir_renames, duplicated.items[i].string, 0);
+ strmap_remove(side2_dir_renames, duplicated.items[i].string, 0);
+ }
+ string_list_clear(&duplicated, 0);
}
/*** Function Grouping: functions related to regular rename detection ***/