zed-industries/zed · error · RuntimeError
git merge-base --is-ancestor failed
Error message
git merge-base --is-ancestor failed
What it means
Once both shas are present locally, the code asks git whether base_sha is an ancestor of main_sha via `git merge-base --is-ancestor`. Git exits 0 for yes and 1 for no; any other exit code means git itself failed (missing object, corrupt repository, usage error), so this RuntimeError is raised with git's decoded stderr when available, otherwise the generic message.
Solutions
- Reproduce by hand: git -C <repo> merge-base --is-ancestor <base_sha> <main_sha>; echo $?
- Run git fsck to detect corruption, then re-fetch or re-clone if it reports errors
- Free disk space — full disks corrupt object writes
- Update git if the installed version is ancient or a wrapper interferes
Example fix
# before # RuntimeError: git merge-base --is-ancestor failed # after git -C $REPO fsck --full # find corruption git -C $REPO fetch --all --prune # repair refs/objects, then retry
Defensive patterns
Strategy: try-catch
Try / catch
try:
on_main = check_ancestry(base_sha, main_sha)
except RuntimeError as err:
if "merge-base" in str(err):
repair_repo(repo_root()) # git fsck + re-fetch, then retry once
on_main = check_ancestry(base_sha, main_sha)
else:
raise Prevention
- Avoid caching .git directories between CI jobs without validation
- Run git fsck periodically on long-lived eval repos
- Treat merge-base exit codes >1 as infrastructure failure, never as a verdict on ancestry
When it happens
Trigger: A corrupted object database after an interrupted fetch; a partial clone where an object referenced by one sha is missing despite ref presence; a damaged .git after disk-full; exotic git versions or wrappers returning unexpected codes.
Common situations: CI caching a broken .git directory between jobs; blob-filtered partial clones on constrained runners; disk-full during earlier git operations.
Understand the failure class
Background: "git command failed": what it means when a tool shells out to git and git exits non-zero — this error's family across 21 libraries.
Related errors
- git merge-base failed
- git diff-tree failed
- git log command failed with
- git log command failed with
- git log failed in with status
AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20).
Data as JSON: /api/errors/5da981b606bbfa33.
Report an issue: GitHub.
Appendix: source
Thrown at crates/eval_cli/zed_eval/source.py:119
if not (commit_present(base_sha) and commit_present(main_sha)):
subprocess.run(
["git", "-C", repo_root(), "fetch", "--quiet", repo_url, "main"],
capture_output=True,
)
if not commit_present(main_sha):
raise RuntimeError(
f"origin/main tip {main_sha[:12]} unavailable locally after fetch"
)
if not commit_present(base_sha):
# Not present even after pulling main's history -> not reachable from main.
return False
ancestry = subprocess.run(
["git", "-C", repo_root(), "merge-base", "--is-ancestor", base_sha, main_sha],
capture_output=True,
)
if ancestry.returncode in (0, 1):
return ancestry.returncode == 0
raise RuntimeError(
(ancestry.stderr or b"").decode(errors="replace").strip()
or "git merge-base --is-ancestor failed"
)
def resolve_git_ref(ref: str) -> str:
return git_output(["rev-parse", "--verify", f"{ref}^{{commit}}"])
_FULL_SHA_RE = re.compile(r"[0-9a-fA-F]{40}")
def resolve_remote_ref(repo_url: str, ref: str) -> str:
"""Resolve a git ref/tag/branch/SHA to a canonical commit SHA against the
*remote* repo, so the resulting build id is identical for every launcher
regardless of what they happen to have fetched locally.
A full 40-char SHA is already canonical and is returned (lowercased) withoutView on GitHub (pinned to f4178619ac)