1

A merge commit can potentially introduce changes that did not appear in any parent commit. For example, when making changes to resolve conflicts or in the case of evil merges. Is there a git command to only see such changes in a merge commit, instead of the default combined-diff format?

torek
  • 448,244
  • 59
  • 642
  • 775
Nasif Imtiaz Ohi
  • 1,563
  • 5
  • 24
  • 45

2 Answers2

3

You audit merge resolutions by rerunning the merge and comparing the automerge result with the recorded result. If the automerge produced conflicts you probably want to look at the resolution even if it's just taking one or the other parents' versions, because, somebody had to choose which and that's a chance for human error right there.

To do this fast, do minimum-checkout merges in a scratch clone.

To make this easier, Git would have to slow down and bulk up every merge, and every repository, and Git's after not doing that.

jthill
  • 55,082
  • 5
  • 77
  • 137
  • Note that merge-ort has, as a small sub-goal, the ability to do this as a cheap-and-easy check. So it might become easier in a new Git version even without fancying up the merge commits themselves. – torek Dec 11 '21 at 01:45
  • @torek you mean merge is going to acquire a re-flight option or something? If it's not in a scratch clone, where's it going to put the results without interfering with your current checkout or making a whole new one? – jthill Dec 11 '21 at 02:56
  • Merge-ort can do the entire merge without touching the working tree, in a temporary index, and hence discover where conflicts are and if there are no conflicts, whether the merge commit itself matches the result of re-merging. – torek Dec 11 '21 at 03:16
1

Mechanical checking of a conflict resolution isn't a coherent concept. After all, the reason this is a "conflict" is exactly that a machine can't do the merge. That's all a merge "conflict" is: it's a merge that needs human intervention.

As for your proposed algorithm, it's incorrect: a "conflict" might quite legitimately be resolved by making changes that don't match the parent or either of the two branch diffs. For example:

base: Hello there
branch1: Hello world
branch2: Goodbye there

That's a "conflict". Resolution:

Goodbye world

That is arguably perfectly right, as it carries out exactly the intentions of both branches; but it doesn't match any of the precedents.

matt
  • 515,959
  • 87
  • 875
  • 1,141