From: Jonathan Nieder <jrnieder@gmail.com>
To: Phillip Susi <psusi@cfl.rr.com>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: log -p hides changes in merge commit
Date: Thu, 6 Jan 2011 15:04:38 -0600 [thread overview]
Message-ID: <20110106210438.GB15090@burratino> (raw)
In-Reply-To: <4D262B05.2060306@cfl.rr.com>
Phillip Susi wrote:
> What I would like to do is be able to review a merge to sign off on it.
> While the full diff against the left parent would be a large and
> unhelpful amalgamation of the changes in the merged branch, any
> additional changes made during the commit should not be hidden. This
> allows someone performing the merge to effectively sneak in unintended
> changes. I would expect any such changes to be shown by log -p, but
> this only seems to happen if you add -c.
To be more precise, here is what -c and --cc do. Consider the
following history (time flowing left to right):
-- [topic]
/
B --- [master]
>From the master branch, I merge topic. (1) If I am lucky, the changes
from B to topic and B to master touch entirely different sections of
code (though perhaps within the same files), so one could just apply
the two diffs in succession to make a merge automatically. (2) Almost
as good is the case when they touch code a couple of lines apart ---
"git merge" still figures it out automatically. (3) Less nice is the
case when they touch the same line, say --- but even here the correct
merge can be obvious. (4) Worst of all is when the changes
semantically conflict but syntactically do not:
$ git merge topic
$ make test; # fails!
$ ... hack hack hack ...
$ git commit --amend
-- o [topic] ------
/ \
B -- o --------------- [master]
In case (1), -c will show a "combined diff" for files where master
does not match either the old master or topic. --cc, on the other
hand, will correctly suppress these uninteresting diffs.
In case (2), -c will show a noisy "combined diff" as before.
--cc will show a combined diff when the changes from both parents
touch nearby code, even if it merged trivially.
In case (3), -c and --cc will show the semantically boring but
syntactically interesting merge.
Case (4) is underspecified. So let's give a more precise example:
the old master and topic tried to fix the same bug in two incompatible
ways. When merging, I decide I like the topic's way better, so I
resolve conflicts in favor of the topic. Hopefully all unrelated
changes on master were preserved!
In this case, -c and --cc will very likely show nothing at all.
Each file matches one of the two parents (old master or topic) so
there is no easy way to distinguish the case from (0) or (1).
By now it should be clear how to get the diff you are looking for.
One makes a test merge, perhaps using the iffy "resolve in favor
of one side or the other" feature to save time on conflicts:
git checkout oldmaster^0
git merge topic
git reset --merge ORIG_HEAD; # meh, too many conflicts
git merge -Xours topic
and then makes a diff.
git diff master
Hope that helps,
Jonathan
next prev parent reply other threads:[~2011-01-06 21:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-06 17:07 log -p hides changes in merge commit Phillip Susi
2011-01-06 19:43 ` Junio C Hamano
2011-01-06 20:50 ` Phillip Susi
2011-01-06 21:04 ` Jonathan Nieder [this message]
2011-01-07 19:27 ` Phillip Susi
2011-01-07 20:27 ` Junio C Hamano
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110106210438.GB15090@burratino \
--to=jrnieder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=psusi@cfl.rr.com \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox