Skip directly to content

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

on Sat Nov 26, 2011

(If you don't see the slideshow below, you can view it on Google docs.)

An interdiff-friendly workflow for revising core patches

  1. Always pull the latest changes.
    git checkout 8.x
    git pull origin 8.x

  2. Create a local branch for the previous patch.
    git checkout -b old_patch

  3. Apply and commit that patch.
    git apply --index old.patch
    git status
    git commit -m "Old patch."

  4. Create a new local branch and make your changes.
    git checkout -b new_patch
    (make changes)
    git add changed_file
    git commit -m "New patch."

  5. Create your new patch with a diff against the main branch.
    git diff 8.x > new.patch

  6. Create your interdiff with a diff against the branch for the other patch.
    git diff old_patch > interdiff.txt

Tip: You can just use git add . instead of staging files individually if you configure your .gitignore to ignore patch files.

Comments

Benedikt Forchhammer's picture

Especially for larger-size patches I imagine that having interdiffs would make reviewing new patch revisions a lot easier!

Hm, maybe this could actually be done automatically with something like dreditor?

Anonymous's picture

On Linux, interdiffs can also be generated from patch files, with the "interdiff" command line tool (part of the "patchutils" package) :

interdiff old.patch new.patch > interdiff.txt

 

BarisW's picture

.. Add the interdiff command with "brew install interdiff"

dstol's picture

With homebrew it's actually 'brew install patchutils'

Benji Fisher's picture

I prefer to do
$ git add -u
which stages any changes to files that are already tracked. If necessary, I
$ git add new_file
for new files.

Naveen Valecha's picture

Really Helpful for me for the first time creating a interdiff.Thanks :)

Post new comment