Improve error message when the upstream branch is wrong.
Otherwise, I get a stack trace, which is annoying. Here's an example:
$ git cl upload
Current branch help_text is up to date.
Failed to diff against upstream branch refs/heads/foo!
This branch probably doesn't exist anymore. To reset the
tracking branch, please run
git branch --set-upstream help_text trunk
replacing trunk with origin/master or the relevant branch
R=dpranke@chromium.org
BUG=
TEST=
Review URL: http://codereview.chromium.org/8349011
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@106175 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/git_cl.py b/git_cl.py
index 58cbd68..9566118 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -495,7 +495,16 @@
# We use the sha1 of HEAD as a name of this change.
name = RunCommand(['git', 'rev-parse', 'HEAD']).strip()
# Need to pass a relative path for msysgit.
- files = scm.GIT.CaptureStatus([root], upstream_branch)
+ try:
+ files = scm.GIT.CaptureStatus([root], upstream_branch)
+ except subprocess2.CalledProcessError:
+ DieWithError(
+ ('\nFailed to diff against upstream branch %s!\n\n'
+ 'This branch probably doesn\'t exist anymore. To reset the\n'
+ 'tracking branch, please run\n'
+ ' git branch --set-upstream %s trunk\n'
+ 'replacing trunk with origin/master or the relevant branch') %
+ (upstream_branch, self.GetBranch()))
issue = ConvertToInteger(self.GetIssue())
patchset = ConvertToInteger(self.GetPatchset())