diff options
author | Josip Sokcevic <sokcevic@google.com> | 2023-10-19 14:46:11 -0700 |
---|---|---|
committer | LUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-10-23 16:13:02 +0000 |
commit | 9267d587273c0f702d04c9c5cb122972f351f3f5 (patch) | |
tree | 12351b848bddf7889e92a6b1dda012f8d4117ab3 /project.py | |
parent | ae824fb2fc2770c84cc34c1956e4c76c8c972860 (diff) | |
download | git-repo-9267d587273c0f702d04c9c5cb122972f351f3f5.tar.gz |
project: Speculative fix for project corruption
When a new shared project is added to manifest, there's a short window
where objects can be deleted that are used by other projects.
To close that window, set preciousObjects during git init. For
non-shared projects, repo should correct the state in the same execution
instance.
Bug: 288102993
Change-Id: I366f524535ac58c820d51a88599ae2108df9ab48
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/390234
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
Tested-by: Josip Sokcevic <sokcevic@google.com>
Reviewed-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'project.py')
-rw-r--r-- | project.py | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -2990,6 +2990,17 @@ class Project: | |||
2990 | self.config.SetBoolean( | 2990 | self.config.SetBoolean( |
2991 | "core.bare", True if self.manifest.IsMirror else None | 2991 | "core.bare", True if self.manifest.IsMirror else None |
2992 | ) | 2992 | ) |
2993 | |||
2994 | if not init_obj_dir: | ||
2995 | # The project might be shared (obj_dir already initialized), but | ||
2996 | # such information is not available here. Instead of passing it, | ||
2997 | # set it as shared, and rely to be unset down the execution | ||
2998 | # path. | ||
2999 | if git_require((2, 7, 0)): | ||
3000 | self.EnableRepositoryExtension("preciousObjects") | ||
3001 | else: | ||
3002 | self.config.SetString("gc.pruneExpire", "never") | ||
3003 | |||
2993 | except Exception: | 3004 | except Exception: |
2994 | if init_obj_dir and os.path.exists(self.objdir): | 3005 | if init_obj_dir and os.path.exists(self.objdir): |
2995 | platform_utils.rmtree(self.objdir) | 3006 | platform_utils.rmtree(self.objdir) |