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

Re: show all merge conflicts

From
G. Sylvie Davies <sylvie@bit-booster.com>
Date
Jan 28, 2017, 05:42 UTC
Message-ID
<CAAj3zPzO4+9t9_L2OXFmkihw-HwFvzybb7GXs4tTeFRyZHOaNQ@mail.gmail.com>
In-Reply-To
<20170127175151.srhhczliqgvbzcre@sigill.intra.peff.net>
On Fri, Jan 27, 2017 at 9:51 AM, Jeff King <peff@peff.net> wrote:
Show 16 quoted lines
> On Fri, Jan 27, 2017 at 11:56:08AM -0500, Michael Spiegel wrote:
>
>> 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.
>

Aside from the usual "git log -cc", I think this should work (replace HEAD with whichever commit you are analyzing):

git diff --name-only HEAD^2...HEAD^1 > m1 git diff --name-only HEAD^1...HEAD^2 > b1 git diff --name-only HEAD^1..HEAD > m2 git diff --name-only HEAD^2..HEAD > b2

If files listed between m1 and b2 differ, then the merge is dirty. Similarly for m2 and b1.

More information here:
http://stackoverflow.com/questions/27683077/how-do-you-detect-an-evil-merge-in-git/41356308#41356308
- Sylvie
Show 23 quoted lines
> 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
Previous: Jeff KingNext: Philip Oakley
Message 3 of 9 in “show all merge conflicts”
  1. Michael SpiegelJan 27, 2017
  2. Jeff KingJan 27, 2017
  3. G. Sylvie DaviesJan 28, 2017
  4. Philip OakleyJan 28, 2017
  5. Jeff KingJan 28, 2017
  6. G. Sylvie DaviesJan 29, 2017
  7. Michael J GruberFeb 27, 2017
  8. Junio C HamanoFeb 27, 2017
  9. Jeff KingFeb 27, 2017

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.