5

If I'm trying to find the diff between two diffs, why can't I just diff the two diffs?

I have tested diff diff1 diff2 and interdiff diff1 diff2 and have not found any difference in the output. In what case would they be different?

(I am fully aware that interdiff's stated purpose is to find the changes between two patches.)

user2946797
  • 171
  • 2
  • 11
  • http://stackoverflow.com/questions/17792768/how-do-i-get-the-interdiff-between-these-two-git-commits Interdiff is the diff between revisions of the same commit, essentially diffs based on the hash. A diff is a diff between different commits altogether. They're honestly just semantics. – gran_profaci Jun 02 '15 at 18:50

2 Answers2

2

Why use interdiff and not just simply diff two patches?

An interdiff tells you whether lines removed in the second patch were added in the first patch, and similarly, whether lines added in the second patch were removed in the first patch. Simply diffing the two commits does not provide this information, forcing the reviewer to consult the original patch or current source to determine whether this is the case.

from Drupal's handbook on Creating an interdiff

Community
  • 1
  • 1
-2

interdiff - show differences between two diff files

interdiff creates a unified format diff that expresses the difference between two diffs.
The diffs must both be relative to the same files.
For best results, the diffs must have at least three lines of context.


An interdiff is a text file in patch format that describes the changes between two versions of a patch. Using interdiffs is a best practice that saves time and reduces tedium for reviewers by allowing them to focus on just the changes introduced in patch iterations.

You should supply one whenever you update a significant patch in the issue queues (it will be ignored by the Drupal.org Testbots, so make sure that you always upload the full patch too).

Create interdiff using git

//Always pull the latest changes.
git pull --rebase

//Create a branch for the old patch.
git checkout -b my_first_branch

// Download the old version of the patch you wish 
// to update and apply it to your local git repository.
git apply --index patchname.patch

// Commit the changes from the old patch.
git commit -m "my_first_branch"

// Depending on how you like to work, you now have a choice between
// two options. If you do not yet have a new patch created, you can now
// create a new branch.
git checkout -b my_second_branch

// Otherwise, let's go back to the mainline branch and create a 
// new branch to patch from.
git checkout any_reuired_commit_id
git checkout -b my_second_branch

// Make your changes on the new branch (e.g. apply your new patch), 
// then commit the changes.
git commit -m "my_second_branch"

// Generate the interdiff by comparing the current (new) branch against 
// the old branch.
git diff my_first_branch > interdiff-my_first_branch-[new_comment_number].txt

// You can create the updated patch easily at this point with:
git diff any_reuired_commit_id > my_second_branch.patch
Community
  • 1
  • 1
CodeWizard
  • 128,036
  • 21
  • 144
  • 167
  • Yes, I understand. But why can't I just run diff on the two diffs? I've tested both `diff diff1 diff2` and `interdiff diff1 diff2` and have not found any difference in the output. – user2946797 Jun 02 '15 at 20:13