Skip to content

Commit c801717

Browse files
newrengitster
authored andcommitted
merge-ort: use histogram diff
In my cursory investigation, histogram diffs are about 2% slower than Myers diffs. Others have probably done more detailed benchmarks. But, in short, histogram diffs have been around for years and in a number of cases provide obviously better looking diffs where Myers diffs are unintelligible but the performance hit has kept them from becoming the default. However, there are real merge bugs we know about that have triggered on git.git and linux.git, which I don't have a clue how to address without the additional information that I believe is provided by histogram diffs. See the following: https://lore.kernel.org/git/[email protected]/ https://lore.kernel.org/git/CABPp-BHvJHpSJT7sdFwfNcPn_sOXwJi3=o14qjZS3M8Rzcxe2A@mail.gmail.com/ https://lore.kernel.org/git/CABPp-BGtez4qjbtFT1hQoREfcJPmk9MzjhY5eEq1QhXT23tFOw@mail.gmail.com/ I don't like mismerges. I really don't like silent mismerges. While I am sometimes willing to make performance and correctness tradeoff, I'm much more interested in correctness in general. I want to fix the above bugs. I have not yet started doing so, but I believe histogram diff at least gives me an angle. Unfortunately, I can't rely on using the information from histogram diff unless it's in use. And it hasn't been used because of a few percentage performance hit. In testcases I have looked at, merge-ort is _much_ faster than merge-recursive for non-trivial merges/rebases/cherry-picks. As such, this is a golden opportunity to switch out the underlying diff algorithm (at least the one used by the merge machinery; git-diff and git-log are separate questions); doing so will allow me to get additional data and improved diffs, and I believe it will help me fix the above bugs at some point in the future. Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e4171b1 commit c801717

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

merge-ort.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "diffcore.h"
2222
#include "strmap.h"
2323
#include "tree.h"
24+
#include "xdiff-interface.h"
2425

2526
struct merge_options_internal {
2627
/*
@@ -245,6 +246,9 @@ static void merge_start(struct merge_options *opt, struct merge_result *result)
245246

246247
assert(opt->priv == NULL);
247248

249+
/* Default to histogram diff. Actually, just hardcode it...for now. */
250+
opt->xdl_opts = DIFF_WITH_ALG(opt, HISTOGRAM_DIFF);
251+
248252
/* Initialization of opt->priv, our internal merge data */
249253
opt->priv = xcalloc(1, sizeof(*opt->priv));
250254

0 commit comments

Comments
 (0)