Last updated February 18, 2015.

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 Testbots, so make sure that you always upload the full patch too).


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

Why using interdiff and not just simply diffing 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.

Make interdiff ignored by the testbot

If you use .diff extension for interdiff add do-not-test before the .diff. Final pattern will be interdiff-[issue_id]-[old_comment_number]-[new_comment_number]-do-not-test.diff.
For example: interdiff-999999-91-92-do-not-test.diff

More information

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


Codenator’s picture

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

Alan D.’s picture

If you already have the patch created, try switching back to the main branch and creating the new branch from there and then applying the patch. Otherwise you will get conflicts trying to apply the updated patch to the updated code (from the original patch).

Alan Davison