usestrix/strix · error · ValueError
Strix requires full git history for diff-scope. Please set f
Error message
Strix requires full git history for diff-scope. Please set fetch-depth: 0 in your CI config.
What it means
Raised by _resolve_repo_diff_scope (utils.py:961) when the repo is a git repository but _is_repo_shallow reports it was cloned with --depth (a .git/shallow file exists). Diff-scope computes merge-base against the base ref, which requires the full history; a shallow clone can make the base unreachable and produce wrong or empty diffs, so Strix refuses upfront.
Source
Thrown at strix/interface/utils.py:961
current_branch = _get_current_branch_name(repo_path)
default_branch = _resolve_default_branch_name(repo_path, env)
if current_branch and default_branch and current_branch != default_branch:
return True
return False
def _resolve_repo_diff_scope(
source: dict[str, str], diff_base: str | None, env: dict[str, str]
) -> RepoDiffScope:
source_path = source.get("source_path", "")
workspace_subdir = source.get("workspace_subdir")
repo_path = Path(source_path)
if not _is_git_repo(repo_path):
raise ValueError(f"Source is not a git repository: {source_path}")
if _is_repo_shallow(repo_path):
raise ValueError(
"Strix requires full git history for diff-scope. Please set fetch-depth: 0 "
"in your CI config."
)
base_ref = _resolve_base_ref(repo_path, diff_base, env)
merge_base_result = _run_git_command(repo_path, ["merge-base", base_ref, "HEAD"], check=False)
if merge_base_result.returncode != 0:
stderr = merge_base_result.stderr.strip()
raise ValueError(
f"Unable to compute merge-base against '{base_ref}' for '{source_path}'. "
f"{stderr or 'Ensure the base branch history is fetched and reachable.'}"
)
merge_base = merge_base_result.stdout.strip()
if not merge_base:
raise ValueError(
f"Unable to compute merge-base against '{base_ref}' for '{source_path}'. "
"Ensure the base branch history is fetched and reachable."View on GitHub (pinned to 8551339130)
Solutions
- In GitHub Actions set 'fetch-depth: 0' on the checkout step (the error message names this exact fix)
- Unshallow an existing clone: git fetch --unshallow (or git fetch --depth=<large>) then re-run
- For GitLab, set GIT_DEPTH: 0 in CI variables
- Clone fresh without --depth for diff-scope runs
Example fix
# before
- uses: actions/checkout@v4 # fetch-depth: 1 (shallow)
- run: strix -t . --diff-scope
# after
- uses: actions/checkout@v4
with:
fetch-depth: 0
- run: strix -t . --diff-scope --diff-base origin/main Defensive patterns
Strategy: validation
Validate before calling
if (Path(source_path) / ".git" / "shallow").exists():
raise SystemExit("shallow clone detected; run `git fetch --unshallow` before diff-scope") Type guard
def is_full_clone(path: str) -> bool:
return not (Path(path) / ".git" / "shallow").exists() Try / catch
try:
run_diff_scope_scan()
except ValueError as e:
if "full git history" in str(e):
subprocess.run(["git", "-C", source_path, "fetch", "--unshallow"], check=True)
run_diff_scope_scan() # retry once unshallowed
else:
raise Prevention
- Set fetch-depth: 0 in actions/checkout for diff-scope jobs
- Set GIT_DEPTH: 0 in GitLab CI
- Never clone with --depth for diff-scope pipelines
When it happens
Trigger: Diff-scope on a repo cloned with git clone --depth=1 or --single-branch; GitHub Actions actions/checkout with default fetch-depth: 1; Docker builds using shallow clones; minimal CI images that default to shallow fetch.
Common situations: actions/checkout@v4 without fetch-depth: 0; GitLab CI default shallow clone (GIT_DEPTH=1); space-saving shallow clones in CI caches; developers reusing CI-built shallow workspaces locally.
Related errors
- Unable to resolve a base ref for diff-scope. Pass --diff-bas
- Source is not a git repository: {source_path}
- Unable to compute merge-base against '{base_ref}' for '{sour
- Unable to compute merge-base against '{base_ref}' for '{sour
- Unable to resolve changed files for '{source_path}'. {stderr
AI-assisted analysis of usestrix/strix@8551339130 (2026-08-15).
Data as JSON: /api/errors/644de9b9f8f9bc7a.
Report an issue: GitHub.