diff options
| -rw-r--r-- | subcmds/sync.py | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py index 8cd1bcac..75512031 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
| @@ -775,19 +775,18 @@ later is required to fix a server side protocol bug. | |||
| 775 | print(f'\r{relpath}: project not found in manifest.', file=sys.stderr) | 775 | print(f'\r{relpath}: project not found in manifest.', file=sys.stderr) |
| 776 | return False | 776 | return False |
| 777 | 777 | ||
| 778 | def _RepairPreciousObjectsState(self, project: Project, opt): | 778 | def _SetPreciousObjectsState(self, project: Project, opt): |
| 779 | """Correct the preciousObjects state for the project. | 779 | """Correct the preciousObjects state for the project. |
| 780 | 780 | ||
| 781 | Args: | 781 | Args: |
| 782 | project (Project): the project to examine, and possibly correct. | 782 | project: the project to examine, and possibly correct. |
| 783 | opt (optparse.Values): options given to sync. | 783 | opt: options given to sync. |
| 784 | """ | 784 | """ |
| 785 | expected = self._GetPreciousObjectsState(project, opt) | 785 | expected = self._GetPreciousObjectsState(project, opt) |
| 786 | actual = project.config.GetBoolean('extensions.preciousObjects') or False | 786 | actual = project.config.GetBoolean('extensions.preciousObjects') or False |
| 787 | relpath = project.RelPath(local = opt.this_manifest_only) | 787 | relpath = project.RelPath(local=opt.this_manifest_only) |
| 788 | 788 | ||
| 789 | if (expected != actual and | 789 | if expected != actual: |
| 790 | not project.config.GetBoolean('repo.preservePreciousObjects')): | ||
| 791 | # If this is unexpected, log it and repair. | 790 | # If this is unexpected, log it and repair. |
| 792 | Trace(f'{relpath} expected preciousObjects={expected}, got {actual}') | 791 | Trace(f'{relpath} expected preciousObjects={expected}, got {actual}') |
| 793 | if expected: | 792 | if expected: |
| @@ -816,13 +815,19 @@ later is required to fix a server side protocol bug. | |||
| 816 | to potentially mark objects precious, so that `git gc` does not discard | 815 | to potentially mark objects precious, so that `git gc` does not discard |
| 817 | shared objects. | 816 | shared objects. |
| 818 | """ | 817 | """ |
| 819 | pm = Progress(f'{"" if opt.auto_gc else "NOT "}Garbage collecting', | 818 | if not opt.auto_gc: |
| 820 | len(projects), delay=False, quiet=opt.quiet) | 819 | # Just repair preciousObjects state, and return. |
| 820 | for project in projects: | ||
| 821 | self._SetPreciousObjectsState(project, opt) | ||
| 822 | return | ||
| 823 | |||
| 824 | pm = Progress('Garbage collecting', len(projects), delay=False, | ||
| 825 | quiet=opt.quiet) | ||
| 821 | pm.update(inc=0, msg='prescan') | 826 | pm.update(inc=0, msg='prescan') |
| 822 | 827 | ||
| 823 | tidy_dirs = {} | 828 | tidy_dirs = {} |
| 824 | for project in projects: | 829 | for project in projects: |
| 825 | self._RepairPreciousObjectsState(project, opt) | 830 | self._SetPreciousObjectsState(project, opt) |
| 826 | 831 | ||
| 827 | project.config.SetString('gc.autoDetach', 'false') | 832 | project.config.SetString('gc.autoDetach', 'false') |
| 828 | # Only call git gc once per objdir, but call pack-refs for the remainder. | 833 | # Only call git gc once per objdir, but call pack-refs for the remainder. |
| @@ -837,10 +842,6 @@ later is required to fix a server side protocol bug. | |||
| 837 | project.bare_git, | 842 | project.bare_git, |
| 838 | ) | 843 | ) |
| 839 | 844 | ||
| 840 | if not opt.auto_gc: | ||
| 841 | pm.end() | ||
| 842 | return | ||
| 843 | |||
| 844 | jobs = opt.jobs | 845 | jobs = opt.jobs |
| 845 | 846 | ||
| 846 | if jobs < 2: | 847 | if jobs < 2: |
