Skip to content

Instantly share code, notes, and snippets.

@jubishop
Forked from natacado/git_diff.rb
Created July 27, 2008 18:20
Show Gist options
  • Save jubishop/2795 to your computer and use it in GitHub Desktop.
Save jubishop/2795 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'tempfile'
require 'rubygems'
require 'mojombo-grit'
include Grit
PATH_TO_DIFFMERGE = "/usr/bin/diffmerge"
repo = Repo.new('.')
head = repo.commits.first
tree = head.tree
blob = tree/ARGV[0]
tempfile = Tempfile.new(blob.name)
tempfile.puts blob.data
tempfile.flush
pid = fork
if pid # parent
Process.wait(pid)
else # child
exec("#{PATH_TO_DIFFMERGE} #{tempfile.path} #{ARGV[0]}")
end
tempfile.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment