From aabf79d3f0736af3bbe9f2e830df6165e06b6ef6 Mon Sep 17 00:00:00 2001 From: Xin Li Date: Thu, 29 Apr 2021 01:50:38 -0700 Subject: [PATCH] sync: Fix a corner case when both superproject and depth used. When depth is used, we would fetch only SHA1 when superproject is used, as the result, only the manifest branch is being recorded, and commands like repo start would fail. Fix this by saving the upstream branch value in the overlay manifest and add the upstream branch to fetch list. Bug: [google internal] b/185951360 Change-Id: Ib36f56067723f2572ed817785b31cc928ddfec0a Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/304562 Reviewed-by: Raman Tenneti Reviewed-by: Jonathan Nieder Tested-by: Xin Li --- project.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/project.py b/project.py index 6679ee31..94c13785 100644 --- a/project.py +++ b/project.py @@ -1214,6 +1214,9 @@ class Project(object): (self.revisionExpr, self.name)) def SetRevisionId(self, revisionId): + if self.clone_depth or self.manifest.manifestProject.config.GetString('repo.depth'): + self.upstream = self.revisionExpr + self.revisionId = revisionId def Sync_LocalHalf(self, syncbuf, force_sync=False, submodules=False): @@ -2134,6 +2137,8 @@ class Project(object): # Shallow checkout of a specific commit, fetch from that commit and not # the heads only as the commit might be deeper in the history. spec.append(branch) + if self.upstream: + spec.append(self.upstream) else: if is_sha1: branch = self.upstream