Re: show all merge conflicts
- From
Jeff King <peff@peff.net>
- Date
- Jan 27, 2017, 17:51 UTC
- Message-ID
- <20170127175151.srhhczliqgvbzcre@sigill.intra.peff.net>
- In-Reply-To
- <CANwu5-o=3p8QfWo9wQvok=UZESRVtF3Uxb3nEMZVv8AvkKYYGw@mail.gmail.com>
On Fri, Jan 27, 2017 at 11:56:08AM -0500, Michael Spiegel wrote:
Show 10 quoted lines
> I'm trying to determine whether a merge required a conflict to resolve > after the merge has occurred. The git book has some advice > (https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging) to use > `git show` on the merge commit or use `git log --cc -p -1`. These > strategies work when the merge conflict was resolved with a change > that is different from either parent. When the conflict is resolved > with a change that is the same as one of the parents, then these > commands are indistinguishable from a merge that did not conflict. Is > it possible to distinguish between a conflict-free merge and a merge > conflict that is resolved by with the changes from one the parents?
No. You'd have to replay the merge to know if it would have had conflicts.
There was a patch series a few years ago that added a new diff-mode to do exactly that, and show the diff against what was resolved. It had a few issues (I don't remember exactly what) and never got merged.
Certainly one complication is that you don't know exactly _how_ the merge was done in the first place (e.g., which merge strategy, which custom merge drivers were in effect, etc). But in general, replaying with a standard merge-recursive would get you most of what you want to know.
I've done this manually sometimes when digging into erroneous merges (e.g., somebody accidentally runs "git reset -- <paths>" in the middle of a merge and throws away some changes.
You should be able to do:
git checkout $merge^1 git merge $merge^2 git diff -R $merge
to see what the original resolution did.
-Peff