summaryrefslogtreecommitdiff
path: root/merge-ort.c
diff options
context:
space:
mode:
authorElijah Newren <newren@gmail.com>2020-12-03 15:59:41 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-12-13 22:21:03 (GMT)
commit101bc5bc2d73484d288a43fdcf1c00bc04b080e4 (patch)
tree15ca7ff128c2b2748cd4599a2aa17e60850ba57c /merge-ort.c
parent67845745c1ab7dcce72116fb58f99630d14e12cc (diff)
downloadgit-101bc5bc2d73484d288a43fdcf1c00bc04b080e4.zip
git-101bc5bc2d73484d288a43fdcf1c00bc04b080e4.tar.gz
git-101bc5bc2d73484d288a43fdcf1c00bc04b080e4.tar.bz2
merge-ort: add a clear_internal_opts helper
Move most of merge_finalize() into a new helper function, clear_internal_opts(). This is a step to facilitate recursive merges, as well as some future optimizations. 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.c40
1 files changed, 24 insertions, 16 deletions
diff --git a/merge-ort.c b/merge-ort.c
index ba3ce8d..ced6be1 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -221,6 +221,29 @@ static void free_strmap_strings(struct strmap *map)
}
}
+static void clear_internal_opts(struct merge_options_internal *opti,
+ int reinitialize)
+{
+ assert(!reinitialize);
+
+ /*
+ * We marked opti->paths with strdup_strings = 0, so that we
+ * wouldn't have to make another copy of the fullpath created by
+ * make_traverse_path from setup_path_info(). But, now that we've
+ * used it and have no other references to these strings, it is time
+ * to deallocate them.
+ */
+ free_strmap_strings(&opti->paths);
+ strmap_clear(&opti->paths, 1);
+
+ /*
+ * All keys and values in opti->conflicted are a subset of those in
+ * opti->paths. We don't want to deallocate anything twice, so we
+ * don't free the keys and we pass 0 for free_values.
+ */
+ strmap_clear(&opti->conflicted, 0);
+}
+
static int err(struct merge_options *opt, const char *err, ...)
{
va_list params;
@@ -1169,22 +1192,7 @@ void merge_finalize(struct merge_options *opt,
assert(opt->priv == NULL);
- /*
- * We marked opti->paths with strdup_strings = 0, so that we
- * wouldn't have to make another copy of the fullpath created by
- * make_traverse_path from setup_path_info(). But, now that we've
- * used it and have no other references to these strings, it is time
- * to deallocate them.
- */
- free_strmap_strings(&opti->paths);
- strmap_clear(&opti->paths, 1);
-
- /*
- * All keys and values in opti->conflicted are a subset of those in
- * opti->paths. We don't want to deallocate anything twice, so we
- * don't free the keys and we pass 0 for free_values.
- */
- strmap_clear(&opti->conflicted, 0);
+ clear_internal_opts(opti, 0);
FREE_AND_NULL(opti);
}