title: git smudge/clean keyword expansion producing wrong results
body: <p>I'm trying to get some info into committed files (I'm a CVS switcher), but the results always seem to be for the previous commit.</p>
  
  <p>I tried using the $Date$ example in Progit.pdf's Keyword Expansion, with similar results. Here are my scripts, which are supposed to replace $Log$ with the commit SHA1 and date, and then restore $Log$ on the way back in:</p>
  
  <h2>smudge</h2>
  
  <pre><code>#! /usr/bin/env ruby
  #
  data = STDIN.read
  info = `git log --pretty=format:"%h on %ad " -1`
  puts data.gsub(/\$Log.*\$/, '$Log: ' + info.to_s + ' $')
  </code></pre>
  
  <h2>clean</h2>
  
  <pre><code>#! /usr/bin/env ruby
  #   
  #
  data = STDIN.read.tr("\r","\n")
  data.sub!(/\$Log.*\$/,"$Log$")     # Replace expanded string, if any, with $Log$
  puts data
  </code></pre>
  
  <p>Thanks for any suggestions.</p>