git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] merge-file: add --diff-algorithm option

From
Antonin Delpeuch <antonin@delpeuch.eu>
Date
Nov 17, 2023, 21:42 UTC
Message-ID
<653b08fd-2df3-4a7a-8082-fdb809e87784@delpeuch.eu>
In-Reply-To
<pull.1606.git.git.1699480494355.gitgitgadget@gmail.com>
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.

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.

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.

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
Previous: Antonin Delpeuch via GitGitGadgetNext: Phillip Wood
Message 2 of 8 in “merge-file: add --diff-algorithm option”
  1. merge-file: add --diff-algorithm optionAntonin Delpeuch via GitGitGadget, Nov 8, 2023
  2. Antonin DelpeuchNov 17, 2023
  3. Phillip WoodNov 19, 2023
  4. Antonin DelpeuchNov 19, 2023
  5. Junio C HamanoNov 19, 2023
  6. Phillip WoodNov 19, 2023
  7. merge-file: add --diff-algorithm optionAntonin Delpeuch via GitGitGadget, Nov 20, 2023
  8. Phillip WoodNov 21, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.