Commit de70b154 authored by iannucci@chromium.org's avatar iannucci@chromium.org

Make udiff print reasonable errors while not on a branch.

R=agable@chromium.org
BUG=

Review URL: https://codereview.chromium.org/212493002

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@259647 0039d316-1c4b-4281-b951-d872f2087c98
parent a8378e2f
......@@ -8,11 +8,10 @@ import sys
import subprocess2
from git_common import current_branch, get_or_create_merge_base, config_list
from git_common import GIT_EXE
import git_common as git
def main(args):
default_args = config_list('depot-tools.upstream-diff.default-args')
default_args = git.config_list('depot-tools.upstream-diff.default-args')
args = default_args + args
parser = argparse.ArgumentParser()
......@@ -22,10 +21,20 @@ def main(args):
'instead of line-wise diff'))
opts, extra_args = parser.parse_known_args(args)
cmd = [GIT_EXE, 'diff', '--patience', '-C', '-C']
cur = git.current_branch()
if not cur or cur == 'HEAD':
print 'fatal: Cannot perform git-upstream-diff while not on a branch'
return 1
par = git.upstream(cur)
if not par:
print 'fatal: No upstream configured for branch \'%s\'' % cur
return 1
cmd = [git.GIT_EXE, 'diff', '--patience', '-C', '-C']
if opts.wordwise:
cmd += ['--word-diff=color', r'--word-diff-regex=(\w+|[^[:space:]])']
cmd += [get_or_create_merge_base(current_branch())]
cmd += [git.get_or_create_merge_base(cur, par)]
cmd += extra_args
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment