From: Junio C Hamano <firstname.lastname@example.org> To: "Neal Kreitzinger" <email@example.com> Cc: firstname.lastname@example.org Subject: Re: 4-way diff (base,ours,theirs,merged) to review merge results Date: Sun, 26 Feb 2012 01:05:14 -0800 [thread overview] Message-ID: <email@example.com> (raw) In-Reply-To: <firstname.lastname@example.org> (Neal Kreitzinger's message of "Sat, 25 Feb 2012 21:55:37 -0600") "Neal Kreitzinger" <email@example.com> writes: > .... 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? Ahh, sorry. While everything I wrote in my previous reply is correct with respect to what happens _during_ a merge until you resolve it, I did not realize that you were asking how to view a merge _after_ it is made. For a two-parent merge $M, "git show --cc $M" runs a three-way diff between $M (merge result), $M^1 (the first parent) and $M^2 (the other parent) and the combined diff it shows is equivalent to: $ git diff --cc $M $M^1 $M^2 Notice the order of parameters. Unlike a normal "diff A B" to ask the command to explain how the state B is reached from state A, you give the result $M and ask the command to explain how it was reached from other states. So in a similar way, running $ git diff --cc $M $M^1 $M^2 $(git merge-base $M^1 $M^2) should show a combined patch that explains the state at $M relative to the states recorded in its parents and the merge base. I've never tried it myself, though, as I never needed such an operation. You can try a trivial example with 4d9e079, which merges 583c389 ec7ff5b and has conflicts in cache.h $ git show 4d9e079 -- cache.h Output omitted; you can see it is the same as the next one for yourself. $ git diff --cc 4d9e079 583c389 ec7ff5b -- cache.h diff --cc cache.h index 3a8e125,24732e6..422c5cf --- a/cache.h +++ b/cache.h @@@ -1177,7 -1176,7 +1177,8 @@@ extern void setup_pager(void) extern const char *pager_program; extern int pager_in_use(void); extern int pager_use_color; +extern int term_columns(void); + extern int decimal_width(int); extern const char *editor_program; extern const char *askpass_program; One side adds term_columns, the other side adds decimal_width. $ git diff --cc 4d9e079 583c389 ec7ff5b \ $(git merge-base 583c389 ec7ff5b) -- cache.h diff --cc cache.h index 3a8e125,24732e6,9bd8c2d..422c5cf --- a/cache.h +++ b/cache.h @@@@ -1177,7 -1176,7 -1176,6 +1177,8 @@@@ extern void setup_pager(void) extern const char *pager_program; extern int pager_in_use(void); extern int pager_use_color; ++extern int term_columns(void); + +extern int decimal_width(int); extern const char *editor_program; extern const char *askpass_program; The third column is a diff between $M and $(git merge-base $M^1 $M^2); the resulting two new lines are indeed shown as additions against the merge base.
prev parent reply other threads:[~2012-02-26 9:06 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-02-26 3:55 Neal Kreitzinger 2012-02-26 8:12 ` Junio C Hamano 2012-02-26 9:05 ` Junio C Hamano [this message]
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style List information: http://vger.kernel.org/majordomo-info.html * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --firstname.lastname@example.org \ --email@example.com \ --firstname.lastname@example.org \ --email@example.com \ --subject='Re: 4-way diff (base,ours,theirs,merged) to review merge results' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
firstname.lastname@example.org list mirror (unofficial, one of many) This inbox may be cloned and mirrored by anyone: git clone --mirror https://public-inbox.org/git git clone --mirror http://ou63pmih66umazou.onion/git git clone --mirror http://czquwvybam4bgbro.onion/git git clone --mirror http://hjrcffqmbrq6wope.onion/git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V1 git git/ https://public-inbox.org/git \ email@example.com public-inbox-index git Example config snippet for mirrors. Newsgroups are available over NNTP: nntp://news.public-inbox.org/inbox.comp.version-control.git nntp://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.version-control.git nntp://ie5yzdi7fg72h7s4sdcztq5evakq23rdt33mfyfcddc5u3ndnw24ogqd.onion/inbox.comp.version-control.git nntp://4uok3hntl7oi7b4uf4rtfwefqeexfzil2w6kgk2jn5z2f764irre7byd.onion/inbox.comp.version-control.git nntp://news.gmane.io/gmane.comp.version-control.git note: .onion URLs require Tor: https://www.torproject.org/ code repositories for project(s) associated with this inbox: https://80x24.org/mirrors/git.git AGPL code for this site: git clone https://public-inbox.org/public-inbox.git