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

Re: How to debug a "git merge"?

From
Jeff King <peff@peff.net>
Date
Mar 15, 2018, 14:09 UTC
Message-ID
<20180315140921.GA27748@sigill.intra.peff.net>
In-Reply-To
<1632E897-B434-4ECC-A236-49C03398DF55@gmail.com>
On Thu, Mar 15, 2018 at 10:51:27AM +0100, Lars Schneider wrote:
Show 7 quoted lines
> > Maybe a stupid question, but: did you make sure that the merge does
> > indeed pick the wrong version of the file? The other option is that
> > somebody mistakenly did a "checkout --ours" or similar while resolving
> > the conflict.
> 
> No stupid question at all. That's exactly what they did and I did not
> realize it! Thank you!

Oh good. :) I have run across this same situation before myself, which is why I thought to ask about it.

Show 12 quoted lines
> Next time I won't stumble over this. I wonder if this is a common enough
> problem to do something about it? For instance what if `git log` (or just
> `git show`) has an option `--verify-merges` or `--reenact-merges` or 
> something? This option would perform a "default recursive merge" and 
> show the diff between the actual merge and the default merge?
> 
> In the most common case there is no diff. If there are merge conflicts
> then we would just show the conflicting files. If there is no merge
> conflict for a file *but* a difference then we would show it. I think
> this would have helped me to realize this kind of problem earlier.
> 
> Would that option make sense to you?

Yes, it's absolutely a good idea, and a frequent wish-list item. The problem is that it's tricky to implement. The only working patches I know of were Thomas Rast's "--remerge-diff" from 2014:

  https://public-inbox.org/git/cover.1409860234.git.tr@thomasrast.ch/

The tricky thing is that you have to actually re-run the diff, and we don't know what options were used for the original diff (e.g., what strategy). And also, merge-recursive really wants to have a valid working tree (though I think maybe that has gotten better over the years).

But even with those warts, I still found it useful in many cases.
-Peff
Previous: Lars SchneiderNext: Elijah Newren
Message 7 of 8 in “How to debug a "git merge"?”
  1. Lars SchneiderMar 14, 2018
  2. Derrick StoleeMar 14, 2018
  3. Lars SchneiderMar 14, 2018
  4. Derrick StoleeMar 20, 2018
  5. Jeff KingMar 14, 2018
  6. Lars SchneiderMar 15, 2018
  7. Jeff KingMar 15, 2018
  8. Elijah NewrenMar 15, 2018

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.