File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -219,6 +219,11 @@ def abs_path(path):
219219 return os .path .join (os .getcwd (), path )
220220
221221
222+ def is_webdiff_from_head ():
223+ '''Was webdiff invoked as `git webdiff` with no other non-flag args?'''
224+ return os .environ .get ('WEBDIFF_FROM_HEAD' ) != None
225+
226+
222227def run ():
223228 global A_DIR , B_DIR , DIFF , PORT
224229 try :
Original file line number Diff line number Diff line change 11#!/usr/bin/env python
22'''This lets you run "git webdiff" instead of "git difftool".'''
33
4+ import os
45import subprocess
56import sys
67
8+
9+ def any_nonflag_args (args ):
10+ """Do any args not start with '-'? If so, this isn't a HEAD diff."""
11+ return len ([x for x in args if not x .startswith ('-' )]) > 0
12+
13+
714def run ():
15+ if not any_nonflag_args (sys .argv [1 :]):
16+ # This tells webdiff that it was invoked as a simple "git webdiff", not
17+ # "git webdiff <sha>". This allows special treatment (e.g. for
18+ # staging diffhunks).
19+ os .environ ['WEBDIFF_FROM_HEAD' ] = 'yes'
20+
821 sys .exit (subprocess .call (
922 'git difftool -d -x webdiff' .split (' ' ) + sys .argv [1 :]))
1023
You can’t perform that action at this time.
0 commit comments