mirror of
https://gerrit.googlesource.com/git-repo
synced 2026-05-09 04:20:00 +00:00
gc: Fix hang during repack in partial clones
Add `--missing=allow-promisor` to `git rev-list` calls in `repack_projects`. This prevents Git from auto-fetching missing objects from the promisor remote, which can cause stalls due to sequential network requests. Also add a Git version check to ensure Git is at least 2.17.0 before running `--repack`, as `--missing=allow-promisor` was introduced in that version. Bug: 500133631 Change-Id: I2dcf9b46fac4c6a53a3c2a46f06f61d6aec40f2f Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/570361 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Gavin Mak <gavinmak@google.com> Reviewed-by: Sam Saccone <samccone@google.com>
This commit is contained in:
+13
-4
@@ -16,6 +16,7 @@ import os
|
||||
from typing import List, Set
|
||||
|
||||
from command import Command
|
||||
from git_command import git_require
|
||||
from git_command import GitCommand
|
||||
import platform_utils
|
||||
from progress import Progress
|
||||
@@ -204,6 +205,7 @@ class Gc(Command):
|
||||
[
|
||||
"rev-list",
|
||||
"--objects",
|
||||
"--missing=allow-promisor",
|
||||
f"--remotes={project.remote.name}",
|
||||
"--filter=blob:none",
|
||||
"--tags",
|
||||
@@ -215,7 +217,12 @@ class Gc(Command):
|
||||
# Get all local objects and pack them.
|
||||
local_head_objects_cmd = GitCommand(
|
||||
project,
|
||||
["rev-list", "--objects", "HEAD^{tree}"],
|
||||
[
|
||||
"rev-list",
|
||||
"--objects",
|
||||
"--missing=allow-promisor",
|
||||
"HEAD^{tree}",
|
||||
],
|
||||
capture_stdout=True,
|
||||
verify_command=True,
|
||||
)
|
||||
@@ -224,6 +231,7 @@ class Gc(Command):
|
||||
[
|
||||
"rev-list",
|
||||
"--objects",
|
||||
"--missing=allow-promisor",
|
||||
"--all",
|
||||
"--reflog",
|
||||
"--indexed-objects",
|
||||
@@ -297,7 +305,8 @@ class Gc(Command):
|
||||
if ret != 0:
|
||||
return ret
|
||||
|
||||
if not opt.repack:
|
||||
return
|
||||
if opt.repack:
|
||||
git_require((2, 17, 0), fail=True, msg="--repack")
|
||||
ret = self.repack_projects(projects, opt)
|
||||
|
||||
return self.repack_projects(projects, opt)
|
||||
return ret
|
||||
|
||||
Reference in New Issue
Block a user