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

4-way diff (base,ours,theirs,merged) to review merge results

From
NKNeal Kreitzinger <neal@rsss.com>
Date
Feb 26, 2012, 03:55 UTC
Message-ID
<jicafn$gnj$1@dough.gmane.org>

Combined diff only tells you what the merge result auto-resolved (with rerere turned off and no merge-conflicts) in comparison to "ours" and "theirs". That only tells you what "ours" and "theirs" *had*, not what they *did* (or were trying to do). You need the merge-base version to see what "ours" and "theirs" did. Seeing what "ours" and "theirs" did will much-better tell you if "merged" did-the-right-thing or not. What is the best way to display a 4-way diff of merge-base, "ours", "theirs", and "merged" after a merge completes so you can review the "merged" results for correctness?

Before I try writing a script to dump the object-contents of the merge-base, "ours", "theirs", and "merged" versions of the-file-in-question to work-files and then feed them to a 4-way diff for review, I would like to see if someone already has a script or better-idea for this, or if git has something more straight-forward that already does-this-for-you.

Reason for this: If "ours" has line-x and "theirs" does not have line-x, and "merged" does have line-x you still have a mystery on your hands:

(Combined diff) ours: has line-x theirs (master): does not have line-x merged: has line-x merge-base (older master): *may-or-may-not* have line-x conclusion: I'm not very sure if "merged" should have line-x or not...

Based on the combined-diff only, I don't know if "merged" should have line-x or not because I don't know if "ours" *added* line-x to the merge-base or if "theirs" *removed* line-x from the merge-base. IOW, if "theirs" is master and "ours" is way-behind master then I pretty-much know I probably need to take "theirs" because it has the latest-stuff. However, I don't know if "theirs" took line-x out of master (and "ours" just has line-x because its old), or if line-x was never in master and "ours" really-needed to add it. Having merge-base context allows for more accurate conclusions like this:

ours: has line-x theirs (master): does not have line-x merged: has line-x merge-base (older master): has line-x conclusion: I should probably take line-x out of "merged"

ours: has line-x theirs (master): does not have line-x merged: has line-x merge-base: does not have line-x conclusion: I should probably keep line-x in "merged"

Thanks in advance for you feedback.

v/r, neal

Next: Junio C Hamano
Message 1 of 3 in “4-way diff (base,ours,theirs,merged) to review merge results”
  1. Neal KreitzingerFeb 26, 2012
  2. Junio C HamanoFeb 26, 2012
  3. Junio C HamanoFeb 26, 2012

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.