Skip to content

Instantly share code, notes, and snippets.

@jubishop
Created July 26, 2008 01:31
Show Gist options
  • Save jubishop/2572 to your computer and use it in GitHub Desktop.
Save jubishop/2572 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
PATH_TO_DIFFMERGE = "/Applications/DiffMerge.app"
at_exit {
call("rm -rf clone/")
}
def call(cmd)
IO.popen(cmd) {|io| io.read }
end
files = call("git diff --cached --name-only").split
fail "No changes." if (files.empty?)
puts "Be patient..."
call("rm -rf clone/")
call("git clone . clone; cd clone/; git reset --hard HEAD")
loop {
puts "Changed files are:"
files.each_with_index{|file, i| puts "\t#{(i+1)}:\t#{file}" }
print "Which shall we diff?:"
num = gets.to_i
if (num == 0 || num > files.length)
puts "Uhhh no, I didn't offer #{num}..."
else
file = files[num-1]
pwd = call("pwd").strip
IO.popen("cd #{PATH_TO_DIFFMERGE}/Contents/MacOs/; ./DiffMerge #{pwd}/clone/#{file} #{pwd}/#{file}")
end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment