As I mentioned in an earlier post entitled “Three commands for Subversion enlightenment“, Subversion’s diff command is quite helpful in determining what local changes have been made.

The output of the diff command is somewhat verbose in that it literally compares the local version to what’s in Subversion. If you’ve made a lot of changes, the output can be overwhelming.

For instance, running the diff command (for a sandbox where only one file has changed) yields output like so:

aglover$ svn diff
Index: test.properties
===================================================================
--- test.properties     (revision 126)
+++ test.properties     (working copy)
@@ -1,5 +1,5 @@
 #HSQL Database Engine
-#Tue Jun 03 10:49:01 EDT 2008
+#Thu Jun 12 17:04:23 EDT 2008
 hsqldb.script_format=0
 runtime.gc_interval=0
 sql.enforce_strict_size=false

In truth, most of the time, I just want to know what has changed not necessarily how. Accordingly, you can pipe the output of diff to a grep-like utility searching for the line containing the word “Index:” like so:

%>svn diff | egrep "Index:"

In my case, I’m using egrep to search for a line of text containing the keyword. If, for some reason, the files you are changing actually contain that word, you might want to precede the phrase with a ^ (which matches the starting position of a line).

Consequently, using this pipe filter yields the following output:

aglover$ svn diff | egrep "Index:"
Index: test.properties

Now I can more easily understand what files have changed and update a repository appropriately.