Diff between commit deltas, not commits themselves
Asked Answered
T

1

7

I have two branches coming from commit a:

a - b - c \ d - e

What I want to see is a diff between the changes introduced in c and e. I can easily view the differences between e and c themselves, but that's not what I want, because that diff includes changes introduced in b and d, and those two commits are different from each other. Abstractly I guess what I want would be something like

diff(diff(b, c), diff(d, e))

Is there a good way to do this? The edits introduced in c and e are only different by maybe 50 lines, so it's not that many, the problem is that this 50 line signal is getting lost in the ~1000 line noise from the difference between b and d. Thanks for the help!

Teresa answered 21/12, 2018 at 1:20 Comment(2)
Are c and e very similar but different a bit? Or c and e are completely not related?Countermine
There is a program that diffs diffs, called "interdiff". It is not part of Git, but you can install it and see if it does what you want.Eagleeyed
T
6

Thanks for the comments, the interdiff lead was enough to help me find the answered question How do I get the interdiff between these two git commits?.

The simple answer (https://mcmap.net/q/21382/-how-do-i-get-the-interdiff-between-these-two-git-commits) was to use
diff <(git log -p -1 c) <(git log -p -1 e)

and the better answer (https://mcmap.net/q/21382/-how-do-i-get-the-interdiff-between-these-two-git-commits ) if you have git 2.19 is the builtin git range-diff. I didn't have that new of a version so I couldn't find it.

Teresa answered 21/12, 2018 at 1:55 Comment(3)
This is the best self-answer I've seen in a long time. Well researched and informative. Also, excellent job balancing out the links to other answers against summarizing the content of the links.Bost
I had forgotten about the new range-diff feature. Note that it's substantially more complex than a simple interdiff, though.Eagleeyed
Why does the "simple" version don't use git show, i.e. something like diff <(git show c) <(git show e)? Seems to be even more simple.Coprolalia

© 2022 - 2024 — McMap. All rights reserved.