From: Jeff King <peff@peff.net>
To: Dov Grobgeld <dov.grobgeld@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: Seeing git history of file including merge changes
Date: Wed, 9 Sep 2015 05:04:27 -0400 [thread overview]
Message-ID: <20150909090427.GA21892@sigill.intra.peff.net> (raw)
In-Reply-To: <CA++fsGHPEMhfENx-35=_9_k7mH98TU8NkHO0pYLC2aSxUKWvyg@mail.gmail.com>
On Wed, Sep 09, 2015 at 11:26:47AM +0300, Dov Grobgeld wrote:
> The file was changed in commit B and the changes were undone in commit M.
>
> My problem is how to view the changes to the file between a specific
> commit, e.g. B and another commit in its "downstream", e.g. H.
>
> If you do
>
> git log -u B..H
>
> you won't see any changes, as the changes due to M are suppressed. You
> can see potential changes by doing:
>
> git log -u --full-history B..H
>
> which will show you that there was a merge commit, but it still won't
> show you the diff between B and M.
>
> So is there a way of seeing all changes made to a file including those
> made by a merge commit?
Try adding "-m". Normally for merges we show nothing, or the combined
diff. In the latter case, we consider a file which matches one of its
parents to be an uninteresting change. From the perspective of walking
back through history, as git-log does, it is impossible to know whether
B made a change that was thrown away in the merge, or whether A made a
change that we kept. You can only know the answer by walking further
back to the merge-base.
Using "-m" will show you the individual diff against each parent. But
since it is limited by the pathspec, it will show you only the diff
against "B" in this case, which is what you want. Using this recipe to
recreate your setup:
# a boring history with a file...
git init
echo base >file
git add file
git commit -m base
# and some other commits...
echo foo >unrelated
git add unrelated
git commit -m unrelated
# meanwhile, somebody forked from us and changed the file...
git checkout -b other HEAD^
echo change >>file && git commit -am change
# now let's merge it in, undoing the change
git checkout master
git merge --no-commit other
echo base >file
git add file
git commit -m merged
I get:
$ git log -p -m --full-history file
commit a279eccbb7cbb806dceff4591a1d4be74b060645 (from 36d29fbf1caf762ef2d78e484bfc1287a9df7603)
Merge: 2d1e518 36d29fb
Author: Jeff King <peff@peff.net>
Date: Wed Sep 9 04:47:26 2015 -0400
merged
diff --git a/file b/file
index 09025f9..df967b9 100644
--- a/file
+++ b/file
@@ -1,2 +1 @@
base
-change
[...and so on, showing "change" and "base" as you'd expect]
That's pretty good, though if you had other merges in your log output, I
expect "-m" would be messy and confusing there.
So I think what you _really_ want is to recompute the original merge and
show something more clever. There is an old topic, tr/remerge-diff,
which tried to do this. Its output looks the same as what is above, but
it would probably do a better job of not making all of the _other_
merges look ugly.
Unfortunately, development stalled on the topic, and it is nowhere close
to being merged. I can dig up pointers if you'd like to play with it.
-Peff
prev parent reply other threads:[~2015-09-09 9:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CA++fsGE-R1XpHxAVRZvOEAAwNr1XdTudGbwE4GYvg-E5L9kqEQ@mail.gmail.com>
2015-09-09 8:26 ` Seeing git history of file including merge changes Dov Grobgeld
2015-09-09 9:04 ` Jeff King [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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150909090427.GA21892@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=dov.grobgeld@gmail.com \
--cc=git@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).