From 7f87c54043ce9a35a5bb60a09ee846f9d7070352 Mon Sep 17 00:00:00 2001 From: Gavin Mak Date: Sat, 6 Dec 2025 00:06:44 +0000 Subject: [PATCH] project: disable auto-gc on fetch for projects with clone-depth=1 This prevents GC hangs on repos with large binaries by skipping implicit GC during network fetch, using clone-depth=1 as a heuristic. Bug: 379111283 Change-Id: I977bf8cd521b11e37eba7ebc9f62120f2bbaf760 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/533802 Tested-by: Gavin Mak Commit-Queue: Gavin Mak Reviewed-by: Mike Frysinger --- project.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/project.py b/project.py index d90a53415..a61c43ed5 100644 --- a/project.py +++ b/project.py @@ -2572,6 +2572,16 @@ class Project: if os.path.exists(os.path.join(self.gitdir, "shallow")): cmd.append("--depth=2147483647") + # Use clone-depth="1" as a heuristic for repositories containing + # large binaries and disable auto GC to prevent potential hangs. + # Check the configured depth because the `depth` argument might be None + # if REPO_ALLOW_SHALLOW=0 converted it to a partial clone. + effective_depth = ( + self.clone_depth or self.manifest.manifestProject.depth + ) + if effective_depth == 1: + cmd.append("--no-auto-gc") + if not verbose: cmd.append("--quiet") if not quiet and sys.stdout.isatty():