git/merge-ort-wrappers.h
Patrick Steinhardt 44ec7c575f merge: fix leaking merge bases
When calling either the recursive or the ORT merge machineries we need
to provide a list of merge bases. The ownership of that parameter is
then implicitly transferred to the callee, which is somewhat fishy.
Furthermore, that list may leak in some cases where the merge machinery
runs into an error, thus causing a memory leak.

Refactor the code such that we stop transferring ownership. Instead, the
merge machinery will now create its own local copies of the passed in
list as required if they need to modify the list. Free the list at the
callsites as required.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-06-11 13:15:08 -07:00

26 lines
644 B
C

#ifndef MERGE_ORT_WRAPPERS_H
#define MERGE_ORT_WRAPPERS_H
#include "merge-recursive.h"
/*
* rename-detecting three-way merge, no recursion.
* Wrapper mimicking the old merge_trees() function.
*/
int merge_ort_nonrecursive(struct merge_options *opt,
struct tree *head,
struct tree *merge,
struct tree *common);
/*
* rename-detecting three-way merge with recursive ancestor consolidation.
* Wrapper mimicking the old merge_recursive() function.
*/
int merge_ort_recursive(struct merge_options *opt,
struct commit *h1,
struct commit *h2,
const struct commit_list *ancestors,
struct commit **result);
#endif