Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Unified Diff: git_upstream_diff.py

Issue 212493002: Make udiff print reasonable errors while not on a branch. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: fix comments Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: git_upstream_diff.py
diff --git a/git_upstream_diff.py b/git_upstream_diff.py
index c7fe1f3449cad367d2d629ed24237bb99589dc2a..9d9db95fd5d64bb1703f15dd38aa6c9270565370 100755
--- a/git_upstream_diff.py
+++ b/git_upstream_diff.py
@@ -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
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698