From 48ea25c6a7f9ca601dc23ca8e32cc2d0dd3f26c2 Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Fri, 20 May 2022 10:35:04 +0000 Subject: [PATCH] sync: start clearing git settings that disabled pruning For projects that no longer share their per-project objects directly, we no longer have to disable the git settings that disable pruning. See commit "project: stop directly sharing objects/ between shared projects" for more details. Bug: https://crbug.com/gerrit/15553 Change-Id: Ica0e83c3002716424c2bc9111b3b3d3a76c30973 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/337535 Reviewed-by: Mike Frysinger Tested-by: LaMont Jones --- subcmds/sync.py | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/subcmds/sync.py b/subcmds/sync.py index 57ee054..507d1c9 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py @@ -657,21 +657,27 @@ later is required to fix a server side protocol bug. tidy_dirs = {} for project in projects: - # Make sure pruning never kicks in with shared projects. + # Make sure pruning never kicks in with shared projects that do not use + # alternates to avoid corruption. if (not project.use_git_worktrees and len(project.manifest.GetProjectsWithName(project.name, all_manifests=True)) > 1): - if not opt.quiet: - print('\r%s: Shared project %s found, disabling pruning.' % - (project.relpath, project.name)) - if git_require((2, 7, 0)): - project.EnableRepositoryExtension('preciousObjects') + if project.UseAlternates: + # Undo logic set by previous versions of repo. + project.config.SetString('extensions.preciousObjects', None) + project.config.SetString('gc.pruneExpire', None) else: - # This isn't perfect, but it's the best we can do with old git. - print('\r%s: WARNING: shared projects are unreliable when using old ' - 'versions of git; please upgrade to git-2.7.0+.' - % (project.relpath,), - file=sys.stderr) - project.config.SetString('gc.pruneExpire', 'never') + if not opt.quiet: + print('\r%s: Shared project %s found, disabling pruning.' % + (project.relpath, project.name)) + if git_require((2, 7, 0)): + project.EnableRepositoryExtension('preciousObjects') + else: + # This isn't perfect, but it's the best we can do with old git. + print('\r%s: WARNING: shared projects are unreliable when using old ' + 'versions of git; please upgrade to git-2.7.0+.' + % (project.relpath,), + file=sys.stderr) + project.config.SetString('gc.pruneExpire', 'never') project.config.SetString('gc.autoDetach', 'false') # Only call git gc once per objdir, but call pack-refs for the remainder. if project.objdir not in tidy_dirs: