mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
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>
This commit is contained in:
parent
ae824fb2fc
commit
9267d58727
11
project.py
11
project.py
@ -2990,6 +2990,17 @@ class Project:
|
|||||||
self.config.SetBoolean(
|
self.config.SetBoolean(
|
||||||
"core.bare", True if self.manifest.IsMirror else None
|
"core.bare", True if self.manifest.IsMirror else None
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if not init_obj_dir:
|
||||||
|
# The project might be shared (obj_dir already initialized), but
|
||||||
|
# such information is not available here. Instead of passing it,
|
||||||
|
# set it as shared, and rely to be unset down the execution
|
||||||
|
# path.
|
||||||
|
if git_require((2, 7, 0)):
|
||||||
|
self.EnableRepositoryExtension("preciousObjects")
|
||||||
|
else:
|
||||||
|
self.config.SetString("gc.pruneExpire", "never")
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
if init_obj_dir and os.path.exists(self.objdir):
|
if init_obj_dir and os.path.exists(self.objdir):
|
||||||
platform_utils.rmtree(self.objdir)
|
platform_utils.rmtree(self.objdir)
|
||||||
|
@ -1129,8 +1129,6 @@ later is required to fix a server side protocol bug.
|
|||||||
)
|
)
|
||||||
project.config.SetString("gc.pruneExpire", "never")
|
project.config.SetString("gc.pruneExpire", "never")
|
||||||
else:
|
else:
|
||||||
if not opt.quiet:
|
|
||||||
print(f"\r{relpath}: not shared, disabling pruning.")
|
|
||||||
project.config.SetString("extensions.preciousObjects", None)
|
project.config.SetString("extensions.preciousObjects", None)
|
||||||
project.config.SetString("gc.pruneExpire", None)
|
project.config.SetString("gc.pruneExpire", None)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user