diff options
author | Xin Li <delphij@google.com> | 2021-06-29 21:42:34 +0000 |
---|---|---|
committer | Xin Li <delphij@google.com> | 2021-06-30 15:31:15 +0000 |
commit | 0e776a5837d08d58cedd1d9e4288ed7db349749c (patch) | |
tree | 28c7c3898923413f0ca6b141671ee811303cfbc5 /project.py | |
parent | 1da6f30579ca6aa698becc0daaf71eaa86237fc8 (diff) | |
download | git-repo-0e776a5837d08d58cedd1d9e4288ed7db349749c.tar.gz |
Fix an issue when syncing with --use-superproject and clone bundles.
It is possible that a clone bundle contained the object referenced by
the branch in the manifest and in the superproject, but not the branch
itself (for example, the branch may be newly created from an existing
branch, or is not vislble to the user downloading the clone bundle).
When --use-superproject is enabled, because we are overriding
revisionExpr with the SHA1 revision provided by the superproject, the
verification step would succeed, but because the expected branch do not
exist, it would confuse git-repo at a later time, as it is expecting the
remote branch to exist in the local clone.
In project.py, fix this by making SetRevisionId() to always remember
the actual branch name and verify it in _CheckForImmutableRevision()
so that we only skip the fetch step when both objects exists locally.
Bug: [google internal] b/191974277
Change-Id: I49d3ca0667f524c8c45f416492faf95b1dd822fb
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/310802
Reviewed-by: Raman Tenneti <rtenneti@google.com>
Reviewed-by: Mike Frysinger <vapier@google.com>
Tested-by: Xin Li <delphij@google.com>
Diffstat (limited to 'project.py')
-rw-r--r-- | project.py | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -1216,7 +1216,7 @@ class Project(object): | |||
1216 | (self.revisionExpr, self.name)) | 1216 | (self.revisionExpr, self.name)) |
1217 | 1217 | ||
1218 | def SetRevisionId(self, revisionId): | 1218 | def SetRevisionId(self, revisionId): |
1219 | if self.clone_depth or self.manifest.manifestProject.config.GetString('repo.depth'): | 1219 | if self.revisionExpr: |
1220 | self.upstream = self.revisionExpr | 1220 | self.upstream = self.revisionExpr |
1221 | 1221 | ||
1222 | self.revisionId = revisionId | 1222 | self.revisionId = revisionId |
@@ -1967,6 +1967,10 @@ class Project(object): | |||
1967 | # throws an error. | 1967 | # throws an error. |
1968 | self.bare_git.rev_list('-1', '--missing=allow-any', | 1968 | self.bare_git.rev_list('-1', '--missing=allow-any', |
1969 | '%s^0' % self.revisionExpr, '--') | 1969 | '%s^0' % self.revisionExpr, '--') |
1970 | if self.upstream: | ||
1971 | rev = self.GetRemote(self.remote.name).ToLocal(self.upstream) | ||
1972 | self.bare_git.rev_list('-1', '--missing=allow-any', | ||
1973 | '%s^0' % rev, '--') | ||
1970 | return True | 1974 | return True |
1971 | except GitError: | 1975 | except GitError: |
1972 | # There is no such persistent revision. We have to fetch it. | 1976 | # There is no such persistent revision. We have to fetch it. |