What changed in that latest patch?

Gerrit is great, but one thing it does not do well is tell you the differences in an update to a review request. Here’s how I found I could focus review requests to just the deltas between submissions.

I’m going to use one of my own patch submissions as an example.

As you can see, Dolph had significant comments on version 7 of the patch. I made a lot of changes, and submitted version 8.

If you want to see what the differences are, you can do so using your own git repository. After cloning the original project, you can use the git lines for each of the patches. It is posted on the change request next to the word Download. I recommend using the “checkout option” and then naming the new branch using a description of the change and the revision number.

Change 7 is

git fetch https://review.openstack.org/openstack/keystone refs/changes/82/17782/7 && git checkout FETCH_HEAD
git checkout -b module-cleanup-patch7

Change 8 is

git fetch https://review.openstack.org/openstack/keystone refs/changes/82/17782/8 && git checkout FETCH_HEAD
git checkout -b module-cleanup-patch8

Now, personally, I find that the git difftool technique of opening each individual file is too slow and clunky. Here’s an improvement.

To generate a diff between the two patches:

 git diff module-cleanup-patch7 module-cleanup-patch8

While Rob Crittenden is amazing in his ability to do a code review from just a patch, I personally find it easier to use a graphical diff tool. I tend to use Kompare. If you use the -o option, it will take a patch and compare it with the underlying file system. Using a dash as the file name makes it read from standard input.

git diff module-cleanup-patch7 module-cleanup-patch8 | kompare -o -

Here’s what it produces:

Clicking through the file list on the left shows the changes in the panel on the right.

4 thoughts on “What changed in that latest patch?

  1. You can use Gerrit to show you diffs between patch set by clicking on the “Old Version History” drop-down that’s under “Dependencies” and above “Patch Set 1″. For example, if you wanted to see the differences between version 7 and version 8, choose “Patch Set 7″ as the “Old Version History”, and Gerrit will show all diffs relative to version 7.

  2. You can also change the base patchset from the gerrit window. When viewing a diff, click on Patch-Sets at the top or you can flip it in the url:

    https://review.openstack.org/#/c/17782/8/keystone/catalog/__init__.py

    If you change it to:

    https://review.openstack.org/#/c/17782/7..8/keystone/catalog/__init__.py

    It will show you the differences between patchsets 7 and 8. The preference is sticky to that review, so make sure to change it back to ‘Base’ to see the whole change.

    Happy Hacking!

    7-22

  3. Hey, all.

    Thanks for the input. I’ve found Gerrits patchset to patchset diffs to be somewhat weird, hence the in-repo review. I’ll try hacking the URL. However, figuring out that I could do:

    git diff HEAD~1 HEAD | kompare -o -

    Is the most valuable part of this.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>