Code Uncategorized

Always check your diffs

One habit that I’ve gotten into that has saved me from looking like an idiot nearly as often is to always look at a diff before I commit. I don’t do this as much in Mercurial, but with SVN when you do automatic deployments to testing servers, a stray alert in your javascript or var_dump in your php can screw up other people’s work. I wrote a small bash script to make it easier for me to check my diffs. Feel free to make it your own. If you have any suggestions for improving it, I’m always looking for ways to improve my dev process. I call it difff for:


difff() {
svn diff > ~/diff.diff
vim ~/diff.diff

EDIT: Make sure to check out the comments below to see Jon Cave’s take on this.

4 replies on “Always check your diffs”

Agreed searching can be pretty useful. You may like to change the branch for no parameters to svn diff | vim - instead then. I have that previous snippet as an alias on ‘v’, but not used as much as the less version.

That’s one of the little things I really like about git; it does the equivalent of svn diff | less by default when you do git diff.

And you can search for text in the output (just like you always can with less) with /[pattern].

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.