diff options
author | LaMont Jones <lamontjones@google.com> | 2022-05-20 10:35:04 +0000 |
---|---|---|
committer | LaMont Jones <lamontjones@google.com> | 2022-07-25 17:13:20 +0000 |
commit | 48ea25c6a7f9ca601dc23ca8e32cc2d0dd3f26c2 (patch) | |
tree | e22f198be392bf7a5d9f9ac9a535bb4868182e38 | |
parent | 355f4398d870573255574c895f808485310b5c10 (diff) | |
download | git-repo-48ea25c6a7f9ca601dc23ca8e32cc2d0dd3f26c2.tar.gz |
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 <vapier@google.com>
Tested-by: LaMont Jones <lamontjones@google.com>
-rw-r--r-- | subcmds/sync.py | 30 |
1 files changed, 18 insertions, 12 deletions
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. | |||
657 | 657 | ||
658 | tidy_dirs = {} | 658 | tidy_dirs = {} |
659 | for project in projects: | 659 | for project in projects: |
660 | # Make sure pruning never kicks in with shared projects. | 660 | # Make sure pruning never kicks in with shared projects that do not use |
661 | # alternates to avoid corruption. | ||
661 | if (not project.use_git_worktrees and | 662 | if (not project.use_git_worktrees and |
662 | len(project.manifest.GetProjectsWithName(project.name, all_manifests=True)) > 1): | 663 | len(project.manifest.GetProjectsWithName(project.name, all_manifests=True)) > 1): |
663 | if not opt.quiet: | 664 | if project.UseAlternates: |
664 | print('\r%s: Shared project %s found, disabling pruning.' % | 665 | # Undo logic set by previous versions of repo. |
665 | (project.relpath, project.name)) | 666 | project.config.SetString('extensions.preciousObjects', None) |
666 | if git_require((2, 7, 0)): | 667 | project.config.SetString('gc.pruneExpire', None) |
667 | project.EnableRepositoryExtension('preciousObjects') | ||
668 | else: | 668 | else: |
669 | # This isn't perfect, but it's the best we can do with old git. | 669 | if not opt.quiet: |
670 | print('\r%s: WARNING: shared projects are unreliable when using old ' | 670 | print('\r%s: Shared project %s found, disabling pruning.' % |
671 | 'versions of git; please upgrade to git-2.7.0+.' | 671 | (project.relpath, project.name)) |
672 | % (project.relpath,), | 672 | if git_require((2, 7, 0)): |
673 | file=sys.stderr) | 673 | project.EnableRepositoryExtension('preciousObjects') |
674 | project.config.SetString('gc.pruneExpire', 'never') | 674 | else: |
675 | # This isn't perfect, but it's the best we can do with old git. | ||
676 | print('\r%s: WARNING: shared projects are unreliable when using old ' | ||
677 | 'versions of git; please upgrade to git-2.7.0+.' | ||
678 | % (project.relpath,), | ||
679 | file=sys.stderr) | ||
680 | project.config.SetString('gc.pruneExpire', 'never') | ||
675 | project.config.SetString('gc.autoDetach', 'false') | 681 | project.config.SetString('gc.autoDetach', 'false') |
676 | # Only call git gc once per objdir, but call pack-refs for the remainder. | 682 | # Only call git gc once per objdir, but call pack-refs for the remainder. |
677 | if project.objdir not in tidy_dirs: | 683 | if project.objdir not in tidy_dirs: |