Is there a way to test if two diffs or patches are equivalent?
Let's say you have the following git commit history, where features F and G are cleanly rebaseable to E:
G
/
A--B--C--D--E
\
F
Due to limitations in our current deployment process, we have the following, somewhat related graph (it's not version controlled)
G'
/
------------E'
\
F'
F' and G' will ultimately be applied to the head E', in some to be determined order, so it would end up like
------------E'--G'--F'
Is there a way to test that the diff from E' to G' is the same as the patch produced by the git commit of G from B?
I fully realize that in an ideal world, revision control would solve this, and we're getting there, but that's not where we are currently.
You could essentially play both patches on separate checkouts and compare the outputs, but that seems kind of clunky. And comparing the diffs themselves, I'm assuming, wouldn't work because line numbers could change. Even if G' and F' were rebased to E', the patch for F' would ultimately be applied to G', making the diff context of the patch different.
git patch-id
andgit cherry
(also see--cherry*
options for git log) might be used as fast answer, but it is too strict and can consider some minor changes as important. Diff of diffs is the way to go when you need certain answer