Re: log -p hides changes in merge commit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]