From acc4c857a0b6e2e33e3647028cbd312498fd5900 Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Thu, 22 Sep 2022 19:05:01 +0000 Subject: [PATCH] sync: only use --cruft when git supports it. git gc --cruft was added in 2.37.0. Bug: https://crbug.com/gerrit/16270 Change-Id: I71e46741e33472a92f16d6f11c51a23e1e55d869 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/346577 Reviewed-by: Emily Shaffer Tested-by: LaMont Jones Reviewed-by: Mike Frysinger --- subcmds/sync.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/subcmds/sync.py b/subcmds/sync.py index 1c49b46e..5818b458 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py @@ -800,7 +800,11 @@ later is required to fix a server side protocol bug. jobs = opt.jobs - gc_args = ('--auto', '--cruft') + gc_args = ['--auto'] + backup_cruft = False + if git_require((2, 37, 0)): + gc_args.append('--cruft') + backup_cruft = True pack_refs_args = () if jobs < 2: for (run_gc, bare_git) in tidy_dirs.values(): @@ -810,7 +814,8 @@ later is required to fix a server side protocol bug. bare_git.gc(*gc_args) else: bare_git.pack_refs(*pack_refs_args) - self._backup_cruft(bare_git) + if backup_cruft: + self._backup_cruft(bare_git) pm.end() return @@ -834,7 +839,8 @@ later is required to fix a server side protocol bug. err_event.set() raise finally: - self._backup_cruft(bare_git) + if backup_cruft: + self._backup_cruft(bare_git) pm.finish(bare_git._project.name) sem.release()