Last updated March 22, 2014.

What is an interdiff and why it is useful?

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).

Example:
interdiff-screenshot.gif

Create interdiff using git

Follow these steps to create an interdiff in your local Git repository:

  1. Always pull the latest changes.
    git pull --rebase
  2. Create a branch for the old patch.
    git checkout -b [issue_id]-[old_comment_number]
  3. Download the old version of the patch you wish to update and apply it to your local git repository.
    git apply --index patchname.patch
  4. Commit the changes from the old patch.
    git commit -m "[issue_id]-[old_comment_number]"
  5. Depending on how you like to work, you now have a choice between two options.
    1. If you do not yet have a new patch created, you can now create a new branch.
      git checkout -b [issue_id]-[new_comment_number]
    2. Otherwise, let's go back to the mainline branch and create a new branch to patch from.
      git checkout 8.x
      git checkout -b [issue_id]-[new_comment_number]
  6. Make your changes on the new branch (e.g. apply your new patch), then commit the changes.
    git commit -m "[issue_id]-[new_comment_number]"
  7. Generate the interdiff by comparing the current (new) branch against the old branch.
    git diff [issue_id]-[old_comment_number] > interdiff-[issue_id]-[old_comment_number]-[new_comment_number].txt
  8. Upload the interdiff to the issue as an attachment along with your updated patch. You can create the updated patch easily at this point with:
    git diff 8.x > [issue_id]-[new_comment_number].patch

Create interdiff using patchutils

Note: You can also create interdiffs by using the interdiff command that is included with patchutils.:

interdiff old.patch new.patch > interdiff-[issue_id]-[old_comment_number]-[new_comment_number].txt

For Mac-users: the easiest way to get the interdiff command available is by using Homebrew with the following command: brew install patchutils

For Debian-ish Linux-users: Install it with: sudo apt-get install patchutils

More information

See also Interdiffs! How to make them, and why they are your friends.

Comments

Using git to create an interdiff, is it not simpler to diff commits?

I was just thinking about this. I would just go for diffing two commits.

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.

When I try after step 5 apply new.patch I got an errors
p.s. I work on windows