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 <gavinmak@google.com> Commit-Queue: Gavin Mak <gavinmak@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
diff --git a/project.py b/project.py index d90a534..a61c43e 100644 --- a/project.py +++ b/project.py
@@ -2572,6 +2572,16 @@ 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():