Force a fetch when superproject has a newer SHA1 for remote branch.

For older git-repo versions, we might have only fetched the SHA1
revision that was provided by the project, but have remote branch left
intact as long as they exist. When the remote branch become stale,
some repo operations like rebase would fail, and repo sync would not
correct this situation.

Fix this by tightening the requirement to also require the superproject
provided SHA1 be an ancestor or equal to the tip-of-tree of the remote
branch.

Bug: [google internal] b/193798453
Change-Id: Ie34c5d860dabb1cbd9f822da929088ec69c79cf6
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/312642
Tested-by: Xin Li <delphij@google.com>
Reviewed-by: Raman Tenneti <rtenneti@google.com>
This commit is contained in:
Xin Li 2021-07-20 20:15:30 +00:00
parent c34b91c9d8
commit 8e983bbc0f

View File

@ -1971,6 +1971,7 @@ class Project(object):
rev = self.GetRemote(self.remote.name).ToLocal(self.upstream) rev = self.GetRemote(self.remote.name).ToLocal(self.upstream)
self.bare_git.rev_list('-1', '--missing=allow-any', self.bare_git.rev_list('-1', '--missing=allow-any',
'%s^0' % rev, '--') '%s^0' % rev, '--')
self.bare_git.merge_base('--is-ancestor', self.revisionExpr, rev)
return True return True
except GitError: except GitError:
# There is no such persistent revision. We have to fetch it. # There is no such persistent revision. We have to fetch it.