Created
February 17, 2010 19:56
-
-
Save hugowetterberg/306959 to your computer and use it in GitHub Desktop.
Script that shows the diff for a file (using git) using Apple's graphical diff tool FileMerge
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
import sys | |
import tempfile | |
import subprocess | |
file = sys.argv[1]; | |
proc = subprocess.Popen(['git', 'ls-tree', 'HEAD'], | |
stdout=subprocess.PIPE, stderr = subprocess.PIPE) | |
output, errors = proc.communicate() | |
for line in output.split("\n"): | |
if len(line) > 0: | |
props, name = line.split('\t') | |
props = props.split(' ') | |
if name == file: | |
blob = props[2] | |
if blob: | |
proc = subprocess.Popen(['git', 'show', blob], | |
stdout=subprocess.PIPE, stderr = subprocess.PIPE) | |
output, errors = proc.communicate() | |
original = tempfile.NamedTemporaryFile('w') | |
original.write(output) | |
original.flush() | |
subprocess.call(['opendiff', original.name, file]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment