From b182658e3ed412e21a472db42ebc37130cee68e0 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 11 Oct 2023 13:37:47 -0700 Subject: merge: introduce {copy|clear}_merge_options() When mostly the same set of options are to be used to perform multiple merges, one instance of the merge_options structure may want to be created and used by copying from the same template instance. We saw such a use recently in "git merge-tree". Let's make the pattern official by introducing copy_merge_options() as a supported way to make a copy of the structure, and also give clear_merge_options() to release any resources held by a copied instance. Currently we only make a shallow copy, so the former is a mere structure assignment while the latter is a no-op, but this may change in the future as the members of merge_options structure evolve. Suggested-by: Jeff King Signed-off-by: Junio C Hamano --- merge-recursive.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'merge-recursive.c') diff --git a/merge-recursive.c b/merge-recursive.c index 0d7e57e2df..e3beb0801b 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -3912,6 +3912,22 @@ void init_merge_options(struct merge_options *opt, opt->buffer_output = 0; } +/* + * For now, members of merge_options do not need deep copying, but + * it may change in the future, in which case we would need to update + * this, and also make a matching change to clear_merge_options() to + * release the resources held by a copied instance. + */ +void copy_merge_options(struct merge_options *dst, struct merge_options *src) +{ + *dst = *src; +} + +void clear_merge_options(struct merge_options *opt UNUSED) +{ + ; /* no-op as our copy is shallow right now */ +} + int parse_merge_opt(struct merge_options *opt, const char *s) { const char *arg; -- cgit 1.2.3-korg