<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Push cx &#187; diff</title>
	<atom:link href="http://push.cx/tag/diff/feed" rel="self" type="application/rss+xml" />
	<link>http://push.cx</link>
	<description>A traveling geek&#039;s blog on development, games, and the web</description>
	<lastBuildDate>Thu, 19 Apr 2012 20:39:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Seeing Subversion Diffs for Commit Messages</title>
		<link>http://push.cx/2007/seeing-subversion-diffs-for-commit-messages</link>
		<comments>http://push.cx/2007/seeing-subversion-diffs-for-commit-messages#comments</comments>
		<pubDate>Wed, 14 Feb 2007 18:20:25 +0000</pubDate>
		<dc:creator>Peter Harkins</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[commit]]></category>
		<category><![CDATA[diff]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[Subversion]]></category>

		<guid isPermaLink="false">http://push.cx/2007/seeing-subversion-diffs-for-commit-messages</guid>
		<description><![CDATA[When I go to check code into a Subversion repository, I like to review a diff of my changes. I can confirm I&#8217;m committing the right files, make sure I didn&#8217;t leave in any debugging statements, and take one last chance to ponder the code. Usually this means doing an svn diff in another window [...]]]></description>
			<content:encoded><![CDATA[<p>
When I go to check code into a Subversion repository, I like to review a diff of my changes. I can confirm I&#8217;m committing the right files, make sure I didn&#8217;t leave in any debugging statements, and take one last chance to ponder the code. Usually this means doing an <kbd>svn diff</kbd> in another window or shelling out of vim to run it. This is a bit awkward, so it&#8217;s easy to forget the step. That&#8217;s backwards, it should be <a href="http://push.cx/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5sb3VkdGhpbmtpbmcuY29tL2FyYy8wMDA2MDEuaHRtbA==">easier to do things right than slack</a>.
</p>

<p>
So I decided to streamline the process (based off <a href="http://push.cx/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3N2bi5oYXh4LnNlL2Rldi9hcmNoaXZlLTIwMDQtMTAvMTE0Ni5zaHRtbA==">this</a>), so that the commit template that svn provides goes from:
</p>

<pre>

--This line, and those below, will be ignored--

M    nearbygamers.com/public/stylesheets/screen.css
</pre>

<p>to:</p>

<pre>

--This line, and those below, will be ignored--

M    nearbygamers.com/public/stylesheets/screen.css

Index: foo
===================================================================
Index: public/stylesheets/screen.css
===================================================================
--- public/stylesheets/screen.css       (revision 360)
+++ public/stylesheets/screen.css       (working copy)
@@ -1,3 +1,6 @@
+h1 {
+  margin-bottom: 0.25em;
+}
 .tag_edit {
   margin-top: 2em;
   font-size: 80%;
</pre>

<p>
First, I have a <kbd>~/bin</kbd> for storing my own commands. In my <kbd>.profile</kbd>, I make sure this is the first thing in my path:
</p>

<pre>&nbsp;
<span style="color: #000066;">export</span> <span style="color: #0000ff;">PATH=</span>~/bin:<span style="color: #0000ff;">$PATH</span></pre>

<p>
Then I added a <kbd>~/bin/svn</kbd> to catch commits, take a diff, and then call my . After saving and setting the execute bit (<kbd>chmod +x ~/bin/svn</kbd>), you&#8217;ll probably have to start a new shell for it to be called.
</p>

<pre>
#!/bin/sh
REALSVN=/usr/bin/svn

ARGS="$@"

if [ "$1" = "commit" -o "$1" = "ci" ]; then
    shift # pop off $1 for diff
    TEMPLATE=`mktemp`
    $REALSVN diff "$@" > "$TEMPLATE"
    $REALSVN $ARGS --editor-cmd="~/bin/svn-diff-editor '$TEMPLATE'"
else
    $REALSVN $ARGS
fi
</pre>

<p>
This called <kbd>~/bin/svn-diff-editor</kbd>, which loads the diff into the commit template and invokes your default editor. (Don&#8217;t forget to set the execute bit on this as well.)
</p>

<pre>
echo >> "$2"
cat "$1" >> "$2"
rm "$1"
$VISUAL "$2"
</pre> <img src="http://push.cx/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=215" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://push.cx/2007/seeing-subversion-diffs-for-commit-messages/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

