summaryrefslogtreecommitdiffstats
path: root/subcmds/sync.py
diff options
context:
space:
mode:
Diffstat (limited to 'subcmds/sync.py')
-rw-r--r--subcmds/sync.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py
index 83c9ad36..b7542cca 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -200,6 +200,9 @@ exist locally.
200The --prune option can be used to remove any refs that no longer 200The --prune option can be used to remove any refs that no longer
201exist on the remote. 201exist on the remote.
202 202
203The --auto-gc option can be used to trigger garbage collection on all
204projects. By default, repo does not run garbage collection.
205
203# SSH Connections 206# SSH Connections
204 207
205If at least one project remote URL uses an SSH connection (ssh://, 208If at least one project remote URL uses an SSH connection (ssh://,
@@ -309,6 +312,10 @@ later is required to fix a server side protocol bug.
309 help='delete refs that no longer exist on the remote (default)') 312 help='delete refs that no longer exist on the remote (default)')
310 p.add_option('--no-prune', dest='prune', action='store_false', 313 p.add_option('--no-prune', dest='prune', action='store_false',
311 help='do not delete refs that no longer exist on the remote') 314 help='do not delete refs that no longer exist on the remote')
315 p.add_option('--auto-gc', action='store_true',
316 help='run garbage collection on all synced projects')
317 p.add_option('--no-auto-gc', dest='auto_gc', action='store_false',
318 help='do not run garbage collection on any projects (default)')
312 if show_smart: 319 if show_smart:
313 p.add_option('-s', '--smart-sync', 320 p.add_option('-s', '--smart-sync',
314 dest='smart_sync', action='store_true', 321 dest='smart_sync', action='store_true',
@@ -829,7 +836,14 @@ later is required to fix a server side protocol bug.
829 project.config.SetString('gc.pruneExpire', None) 836 project.config.SetString('gc.pruneExpire', None)
830 837
831 def _GCProjects(self, projects, opt, err_event): 838 def _GCProjects(self, projects, opt, err_event):
832 pm = Progress('Garbage collecting', len(projects), delay=False, quiet=opt.quiet) 839 """Perform garbage collection.
840
841 If We are skipping garbage collection (opt.auto_gc not set), we still want
842 to potentially mark objects precious, so that `git gc` does not discard
843 shared objects.
844 """
845 pm = Progress(f'{"" if opt.auto_gc else "NOT "}Garbage collecting',
846 len(projects), delay=False, quiet=opt.quiet)
833 pm.update(inc=0, msg='prescan') 847 pm.update(inc=0, msg='prescan')
834 848
835 tidy_dirs = {} 849 tidy_dirs = {}
@@ -849,6 +863,10 @@ later is required to fix a server side protocol bug.
849 project.bare_git, 863 project.bare_git,
850 ) 864 )
851 865
866 if not opt.auto_gc:
867 pm.end()
868 return
869
852 jobs = opt.jobs 870 jobs = opt.jobs
853 871
854 gc_args = ['--auto'] 872 gc_args = ['--auto']