Skip to content

Commit e79bdb4

Browse files
newrengitster
authored andcommitted
merge-ort: extract handling of priv member into reusable function
In preparation for a subsequent commit which will ensure we do not forget to maintain our invariants for the priv member in error codepaths, extract the necessary functionality out into a separate function. This change is cosmetic at this point, and introduces no changes beyond an extra assertion sanity check. Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d63586c commit e79bdb4

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

merge-ort.c

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5000,6 +5000,26 @@ static void merge_check_renames_reusable(struct merge_result *result,
50005000

50015001
/*** Function Grouping: merge_incore_*() and their internal variants ***/
50025002

5003+
static void move_opt_priv_to_result_priv(struct merge_options *opt,
5004+
struct merge_result *result)
5005+
{
5006+
/*
5007+
* opt->priv and result->priv are a bit weird. opt->priv contains
5008+
* information that we can re-use in subsequent merge operations to
5009+
* enable our cached renames optimization. The best way to provide
5010+
* that to subsequent merges is putting it in result->priv.
5011+
* However, putting it directly there would mean retrofitting lots
5012+
* of functions in this file to also take a merge_result pointer,
5013+
* which is ugly and annoying. So, we just make sure at the end of
5014+
* the merge (the outer merge if there are internal recursive ones)
5015+
* to move it.
5016+
*/
5017+
assert(opt->priv && !result->priv);
5018+
result->priv = opt->priv;
5019+
result->_properly_initialized = RESULT_INITIALIZED;
5020+
opt->priv = NULL;
5021+
}
5022+
50035023
/*
50045024
* Originally from merge_trees_internal(); heavily adapted, though.
50055025
*/
@@ -5060,11 +5080,8 @@ static void merge_ort_nonrecursive_internal(struct merge_options *opt,
50605080
/* existence of conflicted entries implies unclean */
50615081
result->clean &= strmap_empty(&opt->priv->conflicted);
50625082
}
5063-
if (!opt->priv->call_depth) {
5064-
result->priv = opt->priv;
5065-
result->_properly_initialized = RESULT_INITIALIZED;
5066-
opt->priv = NULL;
5067-
}
5083+
if (!opt->priv->call_depth)
5084+
move_opt_priv_to_result_priv(opt, result);
50685085
}
50695086

50705087
/*

0 commit comments

Comments
 (0)