From 909d58b2e2e3695ecfa80a54b8700fb889a02677 Mon Sep 17 00:00:00 2001 From: Nasser Grainawi Date: Fri, 19 Sep 2014 12:13:04 -0600 Subject: Support specifying non-HEADS refs as upstream While not typical, some users might have an upstream that isn't in the usual refs/heads/* namespace. There's no reason not to use those refs as the value for the upstream attribute, so support doing so. Change-Id: I5b119f1135c3268c20e7c4084682e860d3ee1fb1 --- project.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'project.py') diff --git a/project.py b/project.py index 95403ccb..e501cc26 100644 --- a/project.py +++ b/project.py @@ -1730,10 +1730,11 @@ class Project(object): if depth: current_branch_only = True + if ID_RE.match(self.revisionExpr) is not None: + is_sha1 = True + if current_branch_only: - if ID_RE.match(self.revisionExpr) is not None: - is_sha1 = True - elif self.revisionExpr.startswith(R_TAGS): + if self.revisionExpr.startswith(R_TAGS): # this is a tag and its sha1 value should never change tag_name = self.revisionExpr[len(R_TAGS):] @@ -1820,9 +1821,10 @@ class Project(object): branch = self.revisionExpr if is_sha1: branch = self.upstream - if branch.startswith(R_HEADS): - branch = branch[len(R_HEADS):] - spec.append(str((u'+refs/heads/%s:' % branch) + remote.ToLocal('refs/heads/%s' % branch))) + if branch is not None and branch.strip(): + if not branch.startswith('refs/'): + branch = R_HEADS + branch + spec.append(str((u'+%s:' % branch) + remote.ToLocal(branch))) cmd.extend(spec) shallowfetch = self.config.GetString('repo.shallowfetch') -- cgit v1.2.3-54-g00ecf