diff --git a/subcmds/sync.py b/subcmds/sync.py index 57ee0540..507d1c94 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: