diff options
author | Josip Sokcevic <sokcevic@chromium.org> | 2023-12-01 23:01:52 +0000 |
---|---|---|
committer | LUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2024-01-03 22:26:07 +0000 |
commit | 9b57aa00f6e8136fd49fdbb29cf669c3dafa2c6b (patch) | |
tree | 03e6aa091018595a067ded0e6028716d69dde927 /project.py | |
parent | b1d1ece2fb0ae62e16c801b0de26736ccf5c77b4 (diff) | |
download | git-repo-9b57aa00f6e8136fd49fdbb29cf669c3dafa2c6b.tar.gz |
project: Check references during sync
Symbolic references need to be checked each time sync is called, not
only for newly created repositories. For example, it is possible to
change a project name to the already existing name, and that will result
in a broken git setup without this patch: refs/ will still point to the
old repository, whereas all objects will point to the new repository.
Bug: 40013418
Change-Id: I596d29d182986804989f0562fb45090224549b0f
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/395798
Reviewed-by: Mike Frysinger <vapier@google.com>
Tested-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
Diffstat (limited to 'project.py')
-rw-r--r-- | project.py | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -1277,7 +1277,20 @@ class Project: | |||
1277 | if is_new: | 1277 | if is_new: |
1278 | self._InitGitDir(force_sync=force_sync, quiet=quiet) | 1278 | self._InitGitDir(force_sync=force_sync, quiet=quiet) |
1279 | else: | 1279 | else: |
1280 | self._UpdateHooks(quiet=quiet) | 1280 | try: |
1281 | # At this point, it's possible that gitdir points to an old | ||
1282 | # objdir (e.g. name changed, but objdir exists). Check | ||
1283 | # references to ensure that's not the case. See | ||
1284 | # https://issues.gerritcodereview.com/40013418 for more | ||
1285 | # details. | ||
1286 | self._CheckDirReference(self.objdir, self.gitdir) | ||
1287 | |||
1288 | self._UpdateHooks(quiet=quiet) | ||
1289 | except GitError as e: | ||
1290 | if not force_sync: | ||
1291 | raise e | ||
1292 | # Let _InitGitDir fix the issue, force_sync is always True here. | ||
1293 | self._InitGitDir(force_sync=True, quiet=quiet) | ||
1281 | self._InitRemote() | 1294 | self._InitRemote() |
1282 | 1295 | ||
1283 | if self.UseAlternates: | 1296 | if self.UseAlternates: |