git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phillip Wood <phillip.wood123@gmail.com>
To: Antonin Delpeuch <antonin@delpeuch.eu>, git@vger.kernel.org
Cc: Elijah Newren <newren@gmail.com>
Subject: Re: [PATCH] merge-file: add --diff-algorithm option
Date: Sun, 19 Nov 2023 16:43:19 +0000	[thread overview]
Message-ID: <de04aec0-a195-45da-8951-bb30f2a629a3@gmail.com> (raw)
In-Reply-To: <653b08fd-2df3-4a7a-8082-fdb809e87784@delpeuch.eu>

Hi Antonin

On 17/11/2023 21:42, Antonin Delpeuch wrote:
> Hi all,
> 
> Here a few more thoughts about this patch, to explain what brought me to 
> needing that. If this need is misguided, perhaps you could redirect me 
> to a better solution.
> 
> I am writing a custom merge driver for Java files. This merge driver 
> internally calls git-merge-file and then solves the merge conflicts 
> which only consist of import statements (there might be cases where it 
> gets it wrong, but I can then use other tools to cleanup those import 
> statements). When testing this, I noticed that the merge driver 
> performed more poorly on other sorts of conflicts, compared to the 
> standard "ort" merge strategy. This is because "ort" uses the 
> "histogram" diff algorithm, which gives better results than the "myers" 
> diff algorithm that merge-file uses.

I cannot comment on this particular use but I think in general calling 
"git merge-file" from a custom merge driver is perfectly sensible. Have 
you tested your driver with this patch to see if you get better results 
with the histogram diff algorithm?

> Intuitively, if "histogram" is the default diff algorithm used by "git 
> merge", then it would also make sense to have the same default for "git 
> merge-file", but I assume that changing this default could be considered 
> a bad breaking change. So I thought that making this diff algorithm 
> configurable would be an acceptable move, hence my patch.

I can see there's an argument for changing the default algorithm of "git 
merge-file" to match what "ort" uses. I know Elijah found the histogram 
algorithm gave better results in his testing when he was developing 
"ort". While it would be a breaking change if on the average the new 
default gives better conflicts it might be worth it. This patch would 
mean that someone wanting to use the "myers" algorithm could still do so.

> Of course, the diffing could be configured in other ways, for instance 
> with its handling of whitespace or EOL (similarly to what the "git-diff" 
> command offers). I think those options would definitely be worth 
> exposing in merge-file as well. If you think this makes sense, then I 
> would be happy to work on a new version of this patch which would 
> attempt to include all the relevant options. I could also try to add the 
> corresponding tests.

It would be nice to see some tests for this patch, ideally using a test 
case that gives different conflicts for "myers" and "histogram". We 
could add the other options later if there is a demand.

Best Wishes

Phillip

> But perhaps my need is misguided? Could it be that I should not be 
> writing a custom merge driver, but instead use another extension point 
> to only process the conflicting hunks after execution of the existing 
> merge driver? I couldn't find such an extension point, but it can well 
> be that I missed it.
> 
> Thank you,
> 
> Antonin
> 
> 

  reply	other threads:[~2023-11-19 16:43 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-08 21:54 [PATCH] merge-file: add --diff-algorithm option Antonin Delpeuch via GitGitGadget
2023-11-17 21:42 ` Antonin Delpeuch
2023-11-19 16:43   ` Phillip Wood [this message]
2023-11-19 19:29     ` Antonin Delpeuch
2023-11-19 23:30     ` Junio C Hamano
2023-11-19 16:42 ` Phillip Wood
2023-11-20 19:18 ` [PATCH v2] " Antonin Delpeuch via GitGitGadget
2023-11-21 14:58   ` Phillip Wood

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=de04aec0-a195-45da-8951-bb30f2a629a3@gmail.com \
    --to=phillip.wood123@gmail.com \
    --cc=antonin@delpeuch.eu \
    --cc=git@vger.kernel.org \
    --cc=newren@gmail.com \
    --cc=phillip.wood@dunelm.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).