summaryrefslogtreecommitdiffstats
path: root/project.py
diff options
context:
space:
mode:
authorDoug Anderson <dianders@google.com>2011-04-07 12:51:04 -0700
committerShawn O. Pearce <sop@google.com>2011-04-07 16:55:35 -0400
commit3ba5f95b46f06ed3d7382346de29ac550d749ec9 (patch)
tree7b38fcbfc0f0237102b4b94b68684b49cb2d0113 /project.py
parent2630dd9787c1b75b70a980175ffa41b63f59e3b8 (diff)
downloadgit-repo-3ba5f95b46f06ed3d7382346de29ac550d749ec9.tar.gz
Fixed repo checkout error message when git reports errors.
In the current version of repo checkout, we often get the error: error: no project has branch xyzzy ...even when the actual error was something else. This fixes it to only report the 'no project has branch' when that is actually true. This fix is very similar to one made for 'repo abandon': https://review.source.android.com/#change,22207 The repo checkout error is filed as: <http://crosbug.com/6514> TEST=manual A sample creating a case where 'git checkout' will fail: $ repo start branch1 . $ repo start branch2 . $ touch bogusfile $ git add bogusfile $ git commit -m "create bogus file" [branch2 f8b6b08] create bogus file 0 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 bogusfile $ echo "More" >> bogusfile $ repo checkout branch1 . error: chromite/: cannot checkout branch1 A sample case showing that we still fail if no project has a branch: $ repo checkout xyzzy . error: no project has branch xyzzy Change-Id: I48a8e258fa7a9c1f2800dafc683787204bbfcc63
Diffstat (limited to 'project.py')
-rw-r--r--project.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/project.py b/project.py
index 7ba1b38a..6252bd68 100644
--- a/project.py
+++ b/project.py
@@ -1167,6 +1167,13 @@ class Project(object):
1167 1167
1168 def CheckoutBranch(self, name): 1168 def CheckoutBranch(self, name):
1169 """Checkout a local topic branch. 1169 """Checkout a local topic branch.
1170
1171 Args:
1172 name: The name of the branch to checkout.
1173
1174 Returns:
1175 True if the checkout succeeded; False if it didn't; None if the branch
1176 didn't exist.
1170 """ 1177 """
1171 rev = R_HEADS + name 1178 rev = R_HEADS + name
1172 head = self.work_git.GetHead() 1179 head = self.work_git.GetHead()
@@ -1181,7 +1188,7 @@ class Project(object):
1181 except KeyError: 1188 except KeyError:
1182 # Branch does not exist in this project 1189 # Branch does not exist in this project
1183 # 1190 #
1184 return False 1191 return None
1185 1192
1186 if head.startswith(R_HEADS): 1193 if head.startswith(R_HEADS):
1187 try: 1194 try: