Message ID | 20210613143155.836591-1-felipe.contreras@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | xdiff: implement a zealous diff3 | expand |
On Sun, Jun 13, 2021 at 09:31:55AM -0500, Felipe Contreras wrote: > From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> > > "zdiff3" is identical to ordinary diff3, only it allows more aggressive > compaction than diff3. This way the displayed base isn't necessary > technically correct, but still this mode might help resolving merge > conflicts between two near identical additions. > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> > --- > > I'm re-sending this patch from 2013 because I do think it provides value > and we might want to make it the default. I take it you didn't investigate the segfault I mentioned. Try this: commit=a5170794372cf1325710a3419473c91ec4af53bf for style in merge diff3 zdiff3; do git reset --hard git checkout $commit^1 git -c merge.conflictstyle=$style merge $commit^2 done The first two are fine; the zdiff3 one segfaults within the xmerge.c code. -Peff
Jeff King wrote: > On Sun, Jun 13, 2021 at 09:31:55AM -0500, Felipe Contreras wrote: > > > From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> > > > > "zdiff3" is identical to ordinary diff3, only it allows more aggressive > > compaction than diff3. This way the displayed base isn't necessary > > technically correct, but still this mode might help resolving merge > > conflicts between two near identical additions. > > > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> > > --- > > > > I'm re-sending this patch from 2013 because I do think it provides value > > and we might want to make it the default. > > I take it you didn't investigate the segfault I mentioned. I don't know how I was supposed to investigate the few segfaults you mentioned. All you said is that you never tracked the bug. > Try this: > > commit=a5170794372cf1325710a3419473c91ec4af53bf > for style in merge diff3 zdiff3; do > git reset --hard > git checkout $commit^1 > git -c merge.conflictstyle=$style merge $commit^2 > done > > The first two are fine; the zdiff3 one segfaults within the xmerge.c > code. I can reproduct the segfault, and here is a simpler way to reproduce it: (I have a hacked version of diff3 until merge-file learns how to use merge.conflictstyle) cat >b <<EOF A EOF cat >l <<EOF A B C D E F GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG H I EOF cat >r <<EOF A b C D E F GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG H i EOF $git merge-file --diff3 -p l b r
Felipe Contreras wrote: > Jeff King wrote: > > Try this: > > > > commit=a5170794372cf1325710a3419473c91ec4af53bf > > for style in merge diff3 zdiff3; do > > git reset --hard > > git checkout $commit^1 > > git -c merge.conflictstyle=$style merge $commit^2 > > done > > > > The first two are fine; the zdiff3 one segfaults within the xmerge.c > > code. > > I can reproduct the segfault, and here is a simpler way to reproduce it: I found the problem, m->chg0 was not initialized in xdl_refine_conflicts. I'm not familiar with the area so I don't know if the following makes sense, but it fixes the crash: --- a/xdiff/xmerge.c +++ b/xdiff/xmerge.c @@ -333,7 +333,7 @@ static int xdl_refine_conflicts(xdfenv_t *xe1, xdfenv_t *xe2, xdmerge_t *m, mmfile_t t1, t2; xdfenv_t xe; xdchange_t *xscr, *x; - int i1 = m->i1, i2 = m->i2; + int i0 = m->i0, i1 = m->i1, i2 = m->i2; /* let's handle just the conflicts */ if (m->mode) @@ -384,6 +384,8 @@ static int xdl_refine_conflicts(xdfenv_t *xe1, xdfenv_t *xe2, xdmerge_t *m, m->next = m2; m = m2; m->mode = 0; + m->i0 = i0; + m->chg0 = 0; m->i1 = xscr->i1 + i1; m->chg1 = xscr->chg1; m->i2 = xscr->i2 + i2;
On Sun, Jun 13, 2021 at 01:00:33PM -0500, Felipe Contreras wrote: > > > I'm re-sending this patch from 2013 because I do think it provides value > > > and we might want to make it the default. > > > > I take it you didn't investigate the segfault I mentioned. > > I don't know how I was supposed to investigate the few segfaults you > mentioned. All you said is that you never tracked the bug. My point is that if you are going to repost a patch that has known problems, it is worth saying so to give reviewers and the maintainer a realistic idea of how stable it is. I also didn't have a reproduction recipe. I found the commit I sent by just re-running every merge in git.git in a loop. It sounds like you have a smaller reproduction and maybe a fix, which is good. -Peff
Felipe Contreras <felipe.contreras@gmail.com> writes: > I found the problem, m->chg0 was not initialized in xdl_refine_conflicts. > > I'm not familiar with the area so I don't know if the following makes > sense, but it fixes the crash: Unlike the remainder of the xdiff/ directory, xdiff/xmerge.c was Dscho's brainchild if I am not mistaken, so I'm CCing him for input. > --- a/xdiff/xmerge.c > +++ b/xdiff/xmerge.c > @@ -333,7 +333,7 @@ static int xdl_refine_conflicts(xdfenv_t *xe1, xdfenv_t *xe2, xdmerge_t *m, > mmfile_t t1, t2; > xdfenv_t xe; > xdchange_t *xscr, *x; > - int i1 = m->i1, i2 = m->i2; > + int i0 = m->i0, i1 = m->i1, i2 = m->i2; > > /* let's handle just the conflicts */ > if (m->mode) > @@ -384,6 +384,8 @@ static int xdl_refine_conflicts(xdfenv_t *xe1, xdfenv_t *xe2, xdmerge_t *m, > m->next = m2; > m = m2; > m->mode = 0; > + m->i0 = i0; > + m->chg0 = 0; > m->i1 = xscr->i1 + i1; > m->chg1 = xscr->chg1; > m->i2 = xscr->i2 + i2;
On Mon, Jun 14, 2021 at 7:07 PM Junio C Hamano <gitster@pobox.com> wrote: > > Felipe Contreras <felipe.contreras@gmail.com> writes: > > > I found the problem, m->chg0 was not initialized in xdl_refine_conflicts. > > > > I'm not familiar with the area so I don't know if the following makes > > sense, but it fixes the crash: > > Unlike the remainder of the xdiff/ directory, xdiff/xmerge.c was > Dscho's brainchild if I am not mistaken, so I'm CCing him for > input. This is going to sound harsh, but people shouldn't waste (any more) time reviewing the patches in this thread or the "merge: cleanups and fix" series submitted elsewhere. They should all just be rejected. I do not think it is reasonable to expect reviewers to spend time responding to re-posted patches when: * no attempt was made to make sure they were up-to-date with current code beyond compiling (see below) * no attempt was made to address missing items pointed out in response to the original submission[1] * no attempt was made to handle or even test particular cases pointed out in response to the original submission (see [1] and below) * the patches were posted despite knowing they caused segfaults, and without even stating as much![2] * the segfault "fixes" are submitted as a separate series from the patch introducing the segfault[3], raising the risk that one gets picked up without the other. In my opinion, these submissions were egregiously cavalier. I'll submit a patch (or perhaps a few) soon that has a functioning zdiff3. However, since I've already put in the time to understand it, let me explain what is wrong with this patch. This particular change is in the area of the code that splits conflict regions when there are portions of the sides (not the base) that match. Doing such splitting makes sense with "merge" conflictStyle since the base is never shown; this splitting can allow pulling the common lines out of the conflict region. However, with diff3 or zdiff3, the original text does not match the sides and by splitting the conflict region, we are forced to decide how or where to split the original text among the various conflict (and non-conflict?) regions. This is pretty haphazard, and the effect of this patch is to assign all of the original text to the first conflict region in the split, and make all other regions have empty base text. This exact scenario was discussed by you and Peff back when zdiff3 was originally introduced in the thread where Felipe got the patch that he started this thread with. In that thread, Peff explained how zdiff3 should only try to move common lines at the beginning or end of the conflict hunk outside the conflict region, without doing any splitting of the conflict region (this particular issue took about 1/3 to 1/2 of the original thread, but I think [4] has a good hilight). Additionally, a quick grep through the code showed that there are additional places in bash/zsh completion that need to be fixed to use the new option besides the locations modified in the original zdiff3 patch. See [1] and [2] for various other things overlooked. [1] https://lore.kernel.org/git/CABPp-BGZ2H1MVgw9RvSdogLMdqsX3n89NkkDYDa2VM3TRHn7tg@mail.gmail.com/ [2] https://lore.kernel.org/git/YMbexfeUG78yBix4@coredump.intra.peff.net/ [3] https://lore.kernel.org/git/20210613225836.1009569-5-felipe.contreras@gmail.com/ [4] https://lore.kernel.org/git/20130307180157.GA6604@sigill.intra.peff.net/
Elijah Newren <newren@gmail.com> writes: > This is going to sound harsh, but people shouldn't waste (any more) > time reviewing the patches in this thread or the "merge: cleanups and > fix" series submitted elsewhere. They should all just be rejected. > > I do not think it is reasonable to expect reviewers to spend time > responding to re-posted patches when: > * no attempt was made to make sure they were up-to-date with current > code beyond compiling (see below) > * no attempt was made to address missing items pointed out in > response to the original submission[1] > * no attempt was made to handle or even test particular cases > pointed out in response to the original submission (see [1] and below) > * the patches were posted despite knowing they caused segfaults, and > without even stating as much![2] > * the segfault "fixes" are submitted as a separate series from the > patch introducing the segfault[3], raising the risk that one gets > picked up without the other. Fair enough. Thanks.
Jeff King wrote: > On Sun, Jun 13, 2021 at 01:00:33PM -0500, Felipe Contreras wrote: > > > > > I'm re-sending this patch from 2013 because I do think it provides value > > > > and we might want to make it the default. > > > > > > I take it you didn't investigate the segfault I mentioned. > > > > I don't know how I was supposed to investigate the few segfaults you > > mentioned. All you said is that you never tracked the bug. > > My point is that if you are going to repost a patch that has known > problems, It was not known that it had problems. That fact that person X said patch Y had a problem doesn't necessarily mean that patch Y has a problem. 1. The problem in the past might not apply in the present 2. The problem X person had might be specific to his/her setup 3. The problem might be due a combination of patches, not the patch itself Plus many others. A logical person sees evidence for what it is, and the only thing that person X saying patch Y had a problem means, is that person X said patch Y had a problem.
Elijah Newren wrote: > On Mon, Jun 14, 2021 at 7:07 PM Junio C Hamano <gitster@pobox.com> wrote: > > > > Felipe Contreras <felipe.contreras@gmail.com> writes: > > > > > I found the problem, m->chg0 was not initialized in xdl_refine_conflicts. > > > > > > I'm not familiar with the area so I don't know if the following makes > > > sense, but it fixes the crash: > > > > Unlike the remainder of the xdiff/ directory, xdiff/xmerge.c was > > Dscho's brainchild if I am not mistaken, so I'm CCing him for > > input. > > This is going to sound harsh, but people shouldn't waste (any more) > time reviewing the patches in this thread or the "merge: cleanups and > fix" series submitted elsewhere. They should all just be rejected. > > I do not think it is reasonable to expect reviewers to spend time > responding to re-posted patches when: > * no attempt was made to make sure they were up-to-date with current > code beyond compiling (see below) What makes you think so? > * no attempt was made to address missing items pointed out in > response to the original submission[1] The original submission caused a discussion with no resolution, and edned with Jeff saying he wanted to try real use-cases and that that he wanted to use it in practice for a while. The purpose v1 of this series was to respark the discussion and see if any of the original parties had changed their minds. People do change their minds after 8 years. > * no attempt was made to handle or even test particular cases > pointed out in response to the original submission (see [1] and below) Those were sent *after* the series, except [4], which clearly states the *opposite* of there being a deal-breaker: But again, we don't do this splitting now. So I don't think it's something that should make or break a decision to have zdiff3. Without the splitting, I can see it being quite useful. > * the patches were posted despite knowing they caused segfaults, and > without even stating as much![2] Whomever *knew* that, it wasn't me. > * the segfault "fixes" are submitted as a separate series from the > patch introducing the segfault[3], raising the risk that one gets > picked up without the other. My v2 includes the patch. Just because a patch is in one series that doesn't preclude it from being in another series. `git merge` and `git rebase` are smart enough to handle such cases. There is no risk of that happening (unless there's plans of merging v1 as-is). > In my opinion, these submissions were egregiously cavalier. If you make unwarranted assumptions everything is possible. > I'll submit a patch (or perhaps a few) soon that has a functioning > zdiff3. I already have a functioning zdiff3. > However, since I've already put in the time to understand it, let me > explain what is wrong with this patch. This particular change is in > the area of the code that splits conflict regions when there are > portions of the sides (not the base) that match. Doing such splitting > makes sense with "merge" conflictStyle since the base is never shown; > this splitting can allow pulling the common lines out of the conflict > region. However, with diff3 or zdiff3, the original text does not > match the sides and by splitting the conflict region, we are forced to > decide how or where to split the original text among the various > conflict (and non-conflict?) regions. This is pretty haphazard, and > the effect of this patch is to assign all of the original text to the > first conflict region in the split, and make all other regions have > empty base text. Yes, that is *one* opinion. The jury is still out on what is the best approach. Junio and Jeff did not agree on that. The whole point of "zdiff3" was to have something closer to "merge", even if it wasn't 100% correct. Your approach maybe more correct, but correctness was never the point. Either way, I have more rewarding things to focus on, so good luck with that. > [1] https://lore.kernel.org/git/CABPp-BGZ2H1MVgw9RvSdogLMdqsX3n89NkkDYDa2VM3TRHn7tg@mail.gmail.com/ > [2] https://lore.kernel.org/git/YMbexfeUG78yBix4@coredump.intra.peff.net/ > [3] https://lore.kernel.org/git/20210613225836.1009569-5-felipe.contreras@gmail.com/ > [4] https://lore.kernel.org/git/20130307180157.GA6604@sigill.intra.peff.net/
Junio C Hamano wrote: > Elijah Newren <newren@gmail.com> writes: > > > This is going to sound harsh, but people shouldn't waste (any more) > > time reviewing the patches in this thread or the "merge: cleanups and > > fix" series submitted elsewhere. They should all just be rejected. > > > > I do not think it is reasonable to expect reviewers to spend time > > responding to re-posted patches when: > > * no attempt was made to make sure they were up-to-date with current > > code beyond compiling (see below) > > * no attempt was made to address missing items pointed out in > > response to the original submission[1] > > * no attempt was made to handle or even test particular cases > > pointed out in response to the original submission (see [1] and below) > > * the patches were posted despite knowing they caused segfaults, and > > without even stating as much![2] > > * the segfault "fixes" are submitted as a separate series from the > > patch introducing the segfault[3], raising the risk that one gets > > picked up without the other. > > Fair enough. Thanks. I didn't know some people's opinions on this mailing list were automatically promoted to facts, but FWIW the vast majority of the points stated above are simply not true.
On Mon, Jun 14, 2021 at 11:19:46PM -0500, Felipe Contreras wrote: > > My point is that if you are going to repost a patch that has known > > problems, > > It was not known that it had problems. > > That fact that person X said patch Y had a problem doesn't necessarily > mean that patch Y has a problem. > > 1. The problem in the past might not apply in the present > 2. The problem X person had might be specific to his/her setup > 3. The problem might be due a combination of patches, not the patch > itself > > Plus many others. > > A logical person sees evidence for what it is, and the only thing that > person X saying patch Y had a problem means, is that person X said patch > Y had a problem. Wow. For one thing, you could still relay the _report_ of a problem along with the patch, which would be valuable information for reviewers. But much more important, in my opinion: that you would dismiss without further investigation a report of a bug from the one person who actually had experience running with the patch implies a level of carelessness that I'm not comfortable with for the project. I had already given up on having substantive discussion with you, but I had hoped I could help the project by pointing out relevant facts in areas that you were working in. But if a simple statement like "this segfaulted for me" is not even useful, then I don't see much point in communicating with you at all. -Peff
Jeff King wrote: > On Mon, Jun 14, 2021 at 11:19:46PM -0500, Felipe Contreras wrote: > > > > My point is that if you are going to repost a patch that has known > > > problems, > > > > It was not known that it had problems. > > > > That fact that person X said patch Y had a problem doesn't necessarily > > mean that patch Y has a problem. > > > > 1. The problem in the past might not apply in the present > > 2. The problem X person had might be specific to his/her setup > > 3. The problem might be due a combination of patches, not the patch > > itself > > > > Plus many others. > > > > A logical person sees evidence for what it is, and the only thing that > > person X saying patch Y had a problem means, is that person X said patch > > Y had a problem. > > Wow. > > For one thing, you could still relay the _report_ of a problem along > with the patch, which would be valuable information for reviewers. Yes I could have, and knowing what I know now I wouldn't even have even posted the patch (not without a proposed fix). Woulda, coulda, shoulda. But that's not the point. The point is that I did not repost a patch with known problems *today*. Nor did I know what kind of problems, or how pervasive the issue was. Presumably you had to try at least 2,500 merges to find *one* issue. I ran all the tests for diff3 with zdiff3 and they passed without problems. Merging this patch would have: 1. Not broken any tests 2. Not changed any behavior for any user 3. Not have caused any problem for the vast majority (> 99%) of people trying out zdiff3 So there was no carelessness here. Moreover, I provied the patch at 9:30, at 10:42 you commented about the segfault, and 16:24 I had the fix. On a Sunday. If this is not caring, I don't know what is.
On Tue, Jun 15, 2021 at 2:16 AM Felipe Contreras <felipe.contreras@gmail.com> wrote: > > Elijah Newren wrote: > > On Mon, Jun 14, 2021 at 7:07 PM Junio C Hamano <gitster@pobox.com> wrote: > > > > > > Felipe Contreras <felipe.contreras@gmail.com> writes: > > > > > > > I found the problem, m->chg0 was not initialized in xdl_refine_conflicts. > > > > > > > > I'm not familiar with the area so I don't know if the following makes > > > > sense, but it fixes the crash: > > > > > > Unlike the remainder of the xdiff/ directory, xdiff/xmerge.c was > > > Dscho's brainchild if I am not mistaken, so I'm CCing him for > > > input. > > > > This is going to sound harsh, but people shouldn't waste (any more) > > time reviewing the patches in this thread or the "merge: cleanups and > > fix" series submitted elsewhere. They should all just be rejected. > > > > I do not think it is reasonable to expect reviewers to spend time > > responding to re-posted patches when: > > * no attempt was made to make sure they were up-to-date with current > > code beyond compiling (see below) > > What makes you think so? I did a simple grep to see where "diff3" was mentioned in the codebase to see if any of those needed a "zdiff3". Among the things I found was that although the original patch updated git-completion.bash, there were additional locations within a current git-completion.bash that referred to "diff3" that should also have a "zdiff3". I know you understand that part of the code. > > * no attempt was made to address missing items pointed out in > > response to the original submission[1] > > The original submission caused a discussion with no resolution The discussion ended with no resolution in part because there were multiple items discussed that would need to be addressed. Including the one reiterated at the end of the discussion. >, and > edned with Jeff saying he wanted to try real use-cases and that that he > wanted to use it in practice for a while. That wasn't the end of the discussion. The email you are referencing occurred here: https://lore.kernel.org/git/20130307185046.GA11622@sigill.intra.peff.net/. The end of the discussion was Junio quoting himself in order to reiterate that "As long as we clearly present the users what the option does and what its implications are, it is not bad to have such an option, I think." See https://lore.kernel.org/git/7vip42gfjc.fsf@alter.siamese.dyndns.org/ and check the timestamps in the threadlist. > > * no attempt was made to handle or even test particular cases > > pointed out in response to the original submission (see [1] and below) > > Those were sent *after* the series, except [4], which clearly states the > *opposite* of there being a deal-breaker: > > But again, we don't do this splitting now. So I don't think it's > something that should make or break a decision to have zdiff3. Without > the splitting, I can see it being quite useful. This statement from Peff was incorrect; the zdiff3 patches made the code do splitting of conflict hunks. I would normally understand if perhaps you didn't know his statement was incorrect and wouldn't have had a way to know, *except* for the fact that this exact patch we are commenting on that you posted is modifying the code that does conflict hunk splitting. Further, you stated at https://lore.kernel.org/git/60c8758c80e13_e633208f7@natae.notmuch/ that you wanted to see conflict hunk splitting in a zdiff3 mode and expected it. So clearly conflict hunk splitting is relevant to you even if it wasn't to Peff. Peff and Junio spent several emails discussing conflict hunk splitting in the original thread (with Junio raising the question multiple times showing it was a concern of his), and Peff spent several emails discussing that topic even assuming that code was never triggered. In contrast to Peff, you know that conflict hunk splitting is relevant since you wanted it to occur, you saw the old thread where they discussed that topic and length, and yet you made no attempt to include a testcase (perhaps even using the one they discussed) to show how the splitting works? I find that negligent. > > * the patches were posted despite knowing they caused segfaults, and > > without even stating as much![2] > > Whomever *knew* that, it wasn't me. You knew that Peff had reported they caused segfaults. He pointed it out after making you aware of the zdiff3 patch; see https://lore.kernel.org/git/YMI+R5LFTj7ezlZE@coredump.intra.peff.net/. You also acknowledged having known of Peff's reports before reposting the patches at https://lore.kernel.org/git/60c82a622ae66_e5292087f@natae.notmuch/ You may be correct to point out that you only knew Peff had reported segfaults, rather than having verified for yourself that there were segfaults. But the fact that you took no action on the knowledge you did have, neither trying to verify, nor asking if the segfaults still occurred, nor even relaying those reports when reposting the patch, is exactly the problem at stake here. I find the lack of action with respect to the segfault report to be reckless. > > * the segfault "fixes" are submitted as a separate series from the > > patch introducing the segfault[3], raising the risk that one gets > > picked up without the other. > > My v2 includes the patch. Ah, so your plan was to post a v2 with the fix as well as *also* post that fix elsewhere? Okay, that makes me feel better about this item, so I retract it. > > In my opinion, these submissions were egregiously cavalier. > > If you make unwarranted assumptions everything is possible. Which assumptions? That you were splitting the segfault fixes into a separate series and not also including them with the patch that introduces the segfault? That does seem unusual and would have been nice if you had communicated your plans somewhere so others wouldn't have to worry about that particular issue, but I agree that your explanation does invalidate the fifth item from my list as a concern. Unfortunately, that still leaves the other four. It's unfair to reviewers to post patches if you have not done due diligence. I've read other patches of yours and commented that I thought they looked good, so I'm not just trying to pick on you. You clearly have talent. With regards to the zdiff3 patches, I've stated above why I think you haven't done your due diligence. Sometimes people make mistakes; that's something that can be corrected. What I find egregious here is that even when Peff and I have pointed out how more due diligence is expected and needed, you've dug in to explain why you think your course of action was reasonable (both here and in https://lore.kernel.org/git/60c82a622ae66_e5292087f@natae.notmuch/). That in my mind raises your submissions from careless to glaringly cavalier. Further, it makes me suspect we may continue to see you repeat such behavior. That worries me.
diff --git a/builtin/merge-file.c b/builtin/merge-file.c index 06a2f90c48..e695867ee5 100644 --- a/builtin/merge-file.c +++ b/builtin/merge-file.c @@ -34,6 +34,8 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix) struct option options[] = { OPT_BOOL('p', "stdout", &to_stdout, N_("send results to standard output")), OPT_SET_INT(0, "diff3", &xmp.style, N_("use a diff3 based merge"), XDL_MERGE_DIFF3), + OPT_SET_INT(0, "zdiff3", &xmp.style, N_("use a zealous diff3 based merge"), + XDL_MERGE_ZEALOUS_DIFF3), OPT_SET_INT(0, "ours", &xmp.favor, N_("for conflicts, use our version"), XDL_MERGE_FAVOR_OURS), OPT_SET_INT(0, "theirs", &xmp.favor, N_("for conflicts, use their version"), diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index b50c5d0ea3..8594559298 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -1566,7 +1566,7 @@ _git_checkout () case "$cur" in --conflict=*) - __gitcomp "diff3 merge" "" "${cur##--conflict=}" + __gitcomp "diff3 merge zdiff3" "" "${cur##--conflict=}" ;; --*) __gitcomp_builtin checkout diff --git a/xdiff-interface.c b/xdiff-interface.c index 609615db2c..9977813a9d 100644 --- a/xdiff-interface.c +++ b/xdiff-interface.c @@ -308,6 +308,8 @@ int git_xmerge_config(const char *var, const char *value, void *cb) die("'%s' is not a boolean", var); if (!strcmp(value, "diff3")) git_xmerge_style = XDL_MERGE_DIFF3; + else if (!strcmp(value, "zdiff3")) + git_xmerge_style = XDL_MERGE_ZEALOUS_DIFF3; else if (!strcmp(value, "merge")) git_xmerge_style = 0; /* diff --git a/xdiff/xdiff.h b/xdiff/xdiff.h index 7a04605146..8629ae287c 100644 --- a/xdiff/xdiff.h +++ b/xdiff/xdiff.h @@ -65,6 +65,7 @@ extern "C" { /* merge output styles */ #define XDL_MERGE_DIFF3 1 +#define XDL_MERGE_ZEALOUS_DIFF3 2 typedef struct s_mmfile { char *ptr; diff --git a/xdiff/xmerge.c b/xdiff/xmerge.c index 1659edb453..95871a0b6e 100644 --- a/xdiff/xmerge.c +++ b/xdiff/xmerge.c @@ -230,7 +230,7 @@ static int fill_conflict_hunk(xdfenv_t *xe1, const char *name1, size += xdl_recs_copy(xe1, m->i1, m->chg1, needs_cr, 1, dest ? dest + size : NULL); - if (style == XDL_MERGE_DIFF3) { + if (style == XDL_MERGE_DIFF3 || style == XDL_MERGE_ZEALOUS_DIFF3) { /* Shared preimage */ if (!dest) { size += marker_size + 1 + needs_cr + marker3_size; @@ -482,6 +482,12 @@ static int xdl_do_merge(xdfenv_t *xe1, xdchange_t *xscr1, int style = xmp->style; int favor = xmp->favor; + /* + * This is the only change between XDL_MERGE_DIFF3 and + * XDL_MERGE_ZEALOUS_DIFF3. "zdiff3" isn't 100% technically correct (as + * the base might be considerably simplified), but still it might help + * interpreting conflicts between two big and near identical additions. + */ if (style == XDL_MERGE_DIFF3) { /* * "diff3 -m" output does not make sense for anything