-
-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathgitwebdiff.py
More file actions
executable file
·32 lines (24 loc) · 861 Bytes
/
Copy pathgitwebdiff.py
File metadata and controls
executable file
·32 lines (24 loc) · 861 Bytes
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
#!/usr/bin/env python
"""This lets you run "git webdiff" instead of "git difftool"."""
import os
import subprocess
import sys
def any_nonflag_args(args):
"""Do any args not start with '-'? If so, this isn't a HEAD diff."""
return len([x for x in args if not x.startswith('-')]) > 0
def run(argv=sys.argv):
if os.environ.get('DEBUG'):
sys.stderr.write(f'git webdiff invoked as: {argv}\n')
try:
cmd = (
'webdiff'
if not os.environ.get('DEBUG')
else os.path.join(os.path.curdir, 'test.sh')
)
os.environ['WEBDIFF_FROM_GIT_DIFFTOOL'] = '1'
subprocess.call(f'git difftool -d -x {cmd}'.split(' ') + argv[1:])
except KeyboardInterrupt:
# Don't raise an exception to the user when sigint is received
pass
if __name__ == '__main__':
run(sys.argv)