forked from danimal/git-chdiff-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-external-chdiff.py
More file actions
executable file
·54 lines (45 loc) · 1.39 KB
/
Copy pathgit-external-chdiff.py
File metadata and controls
executable file
·54 lines (45 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python
# encoding: utf-8
"""
git-external-chdiff
Created by Dan Weeks (dan [AT] danimal [DOT] org) on 2008-02-27.
Released to the Public Domain.
"""
import sys
import subprocess
import os
help_message = '''
git-external-chdiff [old-file] [new-file]
display diffs of git files using the chdiff utility
as a proxy for GIT_EXTERNAL_DIFF via git
'''
def main(argv=None):
"""
the basic work location
"""
# set up the defaults
wait = True
verbose = False
# pull the file names from the args passed in via git
oldFile = sys.argv[2]
newFile = sys.argv[5]
try:
waitFlag = ''
if wait:
waitFlag = '--wait'
if verbose:
print 'git-external-chdiff: comparing %s %s' % (oldFile, newFile)
p = subprocess.Popen('chdiff %s %s %s' % (waitFlag,
oldFile,
newFile),
env=os.environ,
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
p.wait()
# ugh, this is sloppy, but we only know to clean up
# if a chdiff wait is specified, so tidy up now
except OSError, e:
print >>sys.stderr, 'Execution failed:', e
if __name__ == '__main__':
sys.exit(main())