Index: git_cl.py |
diff --git a/git_cl.py b/git_cl.py |
index 26f04fd8c8289ba838902f272f11346a7ef626c3..0d87137a7cf1be1d2533fb80b55f81b065fcb1bb 100755 |
--- a/git_cl.py |
+++ b/git_cl.py |
@@ -138,6 +138,13 @@ def IsGitVersionAtLeast(min_version): |
LooseVersion(version[len(prefix):]) >= LooseVersion(min_version)) |
+def BranchExists(branch): |
+ """Return True if specified branch exists.""" |
+ code, _ = RunGitWithCode(['rev-parse', '--verify', branch], |
+ suppress_stderr=True) |
+ return not code |
+ |
+ |
def ask_for_data(prompt): |
try: |
return raw_input(prompt) |
@@ -718,8 +725,12 @@ or verify this branch is set up to track another (via the --track argument to |
return remote, upstream_branch |
def GetCommonAncestorWithUpstream(self): |
+ upstream_branch = self.GetUpstreamBranch() |
+ if not BranchExists(upstream_branch): |
+ DieWithError('The upstream for the current branch (%s) does not exist ' |
+ 'anymore.\nPlease fix it and try again.' % self.GetBranch()) |
return git_common.get_or_create_merge_base(self.GetBranch(), |
- self.GetUpstreamBranch()) |
iannucci
2015/06/08 18:01:56
why not have GetUpstreamBranch do this check?
pgervais
2015/06/08 20:48:16
I wasn't sure it wouldn't break something else, li
pgervais
2015/06/08 22:23:13
Well, it would break CMDupstream, when it's used t
|
+ upstream_branch) |
def GetUpstreamBranch(self): |
if self.upstream_branch is None: |