mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-11-16 19:36:54 +00:00
git 2.53+ `index-pack --promisor` hands every object outside the promisor packs to pack-objects, which BUG()s (should_include_obj) on the missing objects those objects lead to. A partial clone with unmarked packs therefore keeps crashing its fetches. The retry added for this ran `git -c remote.origin.promisor= fetch`. That override does nothing: git registers promisor remotes additively, so the repo's own `true` still wins (GIT_TRACE on 2.50 and 2.55 shows `index-pack --promisor` and `filter tree:0` under the override). The retry only passed when the crashed fetch had already stored the pack; a retry that has to transfer again crashed again. - On the crash, give every pack without a `.promisor` marker one, then retry the same fetch once. The clone stays partial, no refetch, no config change. If git still crashes, the updater points at the docs section. - The two fetches that turn a full clone partial now mark the clone's old packs afterwards: the depth-1 `tree:0` unshallow in `fetch_full_commit_graph`, and `worktree_ops._deepen_shallow_repo` (`--filter=blob:none`). git writes the partial-clone config before it fetches, so this also runs when the fetch fails. Without it, a converted depth-1 install crashed every later fetch on git 2.55 (3 of 3 rounds in a local repro).
62 lines
2.7 KiB
Python
62 lines
2.7 KiB
Python
"""A shallow checkout is unshallowed (commit graph only) before the updater's bounded fetch.
|
|
|
|
From a depth-1 install far behind main, a plain ``git fetch origin main`` drags in ~the whole
|
|
history and cannot finish inside the 300s network cap (#123254); a ``--depth`` pre-fetch grafts
|
|
origin/main so merge-base reports orphan divergence (#123346). Real local git repositories.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import subprocess
|
|
from pathlib import Path
|
|
|
|
from hermes_cli.gitlock import heal_shallow_history
|
|
|
|
|
|
def _git(cwd: Path, *args: str) -> subprocess.CompletedProcess:
|
|
return subprocess.run(["git", "-c", "user.email=t@t", "-c", "user.name=t", *args], cwd=cwd,
|
|
capture_output=True, text=True, encoding="utf-8", errors="replace")
|
|
|
|
|
|
def _origin(tmp_path: Path, commits: int) -> Path:
|
|
origin = tmp_path / "origin"
|
|
origin.mkdir()
|
|
_git(origin, "init", "-q", "-b", "main")
|
|
_git(origin, "config", "uploadpack.allowFilter", "true")
|
|
for i in range(commits):
|
|
(origin / "f.txt").write_text(f"{i}\n", encoding="utf-8")
|
|
_git(origin, "add", "f.txt")
|
|
_git(origin, "commit", "-qm", f"c{i}")
|
|
return origin
|
|
|
|
|
|
def test_depth1_clone_of_a_tagless_origin_gets_its_commit_graph(tmp_path):
|
|
origin = _origin(tmp_path, 3)
|
|
clone = tmp_path / "clone"
|
|
_git(tmp_path, "clone", "-q", "--depth", "1", f"file://{origin}", str(clone))
|
|
|
|
assert heal_shallow_history(clone, "main") is True
|
|
|
|
assert _git(clone, "rev-parse", "--is-shallow-repository").stdout.strip() == "false"
|
|
assert _git(clone, "rev-list", "--count", "HEAD").stdout.strip() == "3"
|
|
# History really was missing: fetched commits-only, as a tree:0 partial clone.
|
|
assert _git(clone, "config", "remote.origin.partialclonefilter").stdout.strip() == "tree:0"
|
|
# The clone's own depth-1 pack is a partial-clone pack now too, or git 2.53+ crashes every
|
|
# later fetch in pack-objects (#124272).
|
|
packs = list((clone / ".git" / "objects" / "pack").glob("pack-*.pack"))
|
|
assert packs and all(p.with_suffix(".promisor").exists() for p in packs)
|
|
|
|
|
|
def test_depth_prefetch_on_a_full_clone_restores_ancestry_and_keeps_it_full(tmp_path):
|
|
origin = _origin(tmp_path, 2)
|
|
clone = tmp_path / "clone"
|
|
_git(tmp_path, "clone", "-q", f"file://{origin}", str(clone))
|
|
(origin / "f.txt").write_text("next\n", encoding="utf-8")
|
|
_git(origin, "commit", "-qam", "next")
|
|
_git(clone, "fetch", "-q", "--depth", "1", "origin", "main")
|
|
assert _git(clone, "merge-base", "HEAD", "origin/main").returncode != 0
|
|
|
|
assert heal_shallow_history(clone, "main") is True
|
|
|
|
assert _git(clone, "merge-base", "--is-ancestor", "HEAD", "origin/main").returncode == 0
|
|
assert _git(clone, "config", "--get", "remote.origin.promisor").returncode != 0
|