Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to compare two diffs or patches?

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.

like image 839
Mark Canlas Avatar asked Dec 20 '11 01:12

Mark Canlas


People also ask

What is the difference between patch and diff?

diff contains only the file changes, while the . patch is a serialization of all commits in that PR, with the commit message and file content diff in each.

How do I compare files in two branches?

Compare specific file between two branches In some cases, you may want to see all changes done to a specific file on the current branch you are working on. In order to see the differences done to a file between two branches, use the “git diff” command, specify the two branches and the filename.

Can you compare two files in github?

You can always perform branch comparisons from Git if you are comfortable interacting directly with the command line tools it offers. Using Git directly gives you access to a couple of distinct commands that make it easy to compare specific parts of your project. Different arguments of git command.

How do you display a list of files added or modified in a specific commit?

OK, there are a couple of ways to show all files in a particular commit... To reduce the information and show only names of the files which committed, you simply can add --name-only or --name-status flag... These flags just show you the file names which are different from previous commits as you want...


1 Answers

diff <(git show COMMIT1SHA) <(git show COMMIT2SHA) 
like image 185
mrbrdo Avatar answered Sep 23 '22 23:09

mrbrdo