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