Skip to content

Commit 101bc5b

Browse files
newrengitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6784574 commit 101bc5b

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

merge-ort.c

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,29 @@ static void free_strmap_strings(struct strmap *map)
221221
}
222222
}
223223

224+
static void clear_internal_opts(struct merge_options_internal *opti,
225+
int reinitialize)
226+
{
227+
assert(!reinitialize);
228+
229+
/*
230+
* We marked opti->paths with strdup_strings = 0, so that we
231+
* wouldn't have to make another copy of the fullpath created by
232+
* make_traverse_path from setup_path_info(). But, now that we've
233+
* used it and have no other references to these strings, it is time
234+
* to deallocate them.
235+
*/
236+
free_strmap_strings(&opti->paths);
237+
strmap_clear(&opti->paths, 1);
238+
239+
/*
240+
* All keys and values in opti->conflicted are a subset of those in
241+
* opti->paths. We don't want to deallocate anything twice, so we
242+
* don't free the keys and we pass 0 for free_values.
243+
*/
244+
strmap_clear(&opti->conflicted, 0);
245+
}
246+
224247
static int err(struct merge_options *opt, const char *err, ...)
225248
{
226249
va_list params;
@@ -1169,22 +1192,7 @@ void merge_finalize(struct merge_options *opt,
11691192

11701193
assert(opt->priv == NULL);
11711194

1172-
/*
1173-
* We marked opti->paths with strdup_strings = 0, so that we
1174-
* wouldn't have to make another copy of the fullpath created by
1175-
* make_traverse_path from setup_path_info(). But, now that we've
1176-
* used it and have no other references to these strings, it is time
1177-
* to deallocate them.
1178-
*/
1179-
free_strmap_strings(&opti->paths);
1180-
strmap_clear(&opti->paths, 1);
1181-
1182-
/*
1183-
* All keys and values in opti->conflicted are a subset of those in
1184-
* opti->paths. We don't want to deallocate anything twice, so we
1185-
* don't free the keys and we pass 0 for free_values.
1186-
*/
1187-
strmap_clear(&opti->conflicted, 0);
1195+
clear_internal_opts(opti, 0);
11881196
FREE_AND_NULL(opti);
11891197
}
11901198

0 commit comments

Comments
 (0)