From: Junio C Hamano <gitster@xxxxxxxxx> Instead of spawning merge-recursive via run_command() in run_fallback_merge_recursive(), make a direct call to the internal merge_recursive_generic(). Here is a quick benchmark result, applying a patch for b4391657 (merge: drop 'git merge <message> HEAD <commit>' syntax, 2015-03-25) that was still cooking in 'next' on 4b1fd356 (git-multimail: update to release 1.2.0, 2015-10-11) which was the tip of 'master' at some stage, on an x86-64 running Ubuntu: real 0m0.169s real 0m0.163s user 0m0.108s user 0m0.134s sys 0m0.068s sys 0m0.033s real 0m0.175s real 0m0.161s user 0m0.110s user 0m0.120s sys 0m0.066s sys 0m0.047s real 0m0.168s real 0m0.162s user 0m0.124s user 0m0.114s sys 0m0.045s sys 0m0.051s real 0m0.167s real 0m0.152s user 0m0.124s user 0m0.122s sys 0m0.045s sys 0m0.031s real 0m0.169s real 0m0.164s user 0m0.131s user 0m0.129s sys 0m0.043s sys 0m0.041s Left-hand side shows the original, right-hand side shows the result of this optimization. Timings on Windows: original: 0.00user 0.01system 0:00.29elapsed 0.00user 0.00system 0:00.25elapsed 0.01user 0.00system 0:00.24elapsed 0.01user 0.00system 0:00.26elapsed 0.00user 0.01system 0:00.23elapsed with optimization: 0.00user 0.01system 0:00.22elapsed 0.00user 0.00system 0:00.25elapsed 0.00user 0.01system 0:00.22elapsed 0.00user 0.00system 0:00.22elapsed 0.01user 0.00system 0:00.21elapsed Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx> Signed-off-by: Johannes Schindelin <johannes.schindelin@xxxxxx> --- It feels *slightly* wrong to submit your own patch to review, however, please keep in mind that 1) I changed the patch (o.gently does not exist anymore, so I do not set it), and 2) I added my own timings performed on Windows. builtin/am.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/builtin/am.c b/builtin/am.c index 3dfe70b..dd41154 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -1587,25 +1587,26 @@ static int run_fallback_merge_recursive(const struct am_state *state, unsigned char *our_tree, unsigned char *his_tree) { - struct child_process cp = CHILD_PROCESS_INIT; + const unsigned char *bases[1] = {orig_tree}; + struct merge_options o; + struct commit *result; + char *his_tree_name; int status; - cp.git_cmd = 1; + init_merge_options(&o); + + o.branch1 = "HEAD"; + his_tree_name = xstrfmt("%.*s", linelen(state->msg), state->msg); + o.branch2 = his_tree_name; - argv_array_pushf(&cp.env_array, "GITHEAD_%s=%.*s", - sha1_to_hex(his_tree), linelen(state->msg), state->msg); if (state->quiet) - argv_array_push(&cp.env_array, "GIT_MERGE_VERBOSITY=0"); + o.verbosity = 0; - argv_array_push(&cp.args, "merge-recursive"); - argv_array_push(&cp.args, sha1_to_hex(orig_tree)); - argv_array_push(&cp.args, "--"); - argv_array_push(&cp.args, sha1_to_hex(our_tree)); - argv_array_push(&cp.args, sha1_to_hex(his_tree)); + status = merge_recursive_generic(&o, our_tree, his_tree, 1, bases, &result); + if (status < 0) + exit(128); + free(his_tree_name); - status = run_command(&cp) ? (-1) : 0; - discard_cache(); - read_cache(); return status; } -- 2.9.0.268.gcabc8b0 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html