dotnet/runtime · error · RuntimeError
Couldn't determine baseline git hash
Error message
Couldn't determine baseline git hash
What it means
Raised by get_baseline_jit when `git merge-base <current_hash> <main_hash>` exits non-zero. The merge-base is needed to find a shared baseline commit between the current HEAD and origin/main.
Source
Thrown at src/coreclr/scripts/superpmi.py:4892
# First find the newest hash for any branch matching */main.
command = [ "git", "branch", "-r", "--sort=-committerdate", "-v", "--list", "*/main" ]
logging.debug("Invoking: %s", " ".join(command))
proc = subprocess.Popen(command, stdout=subprocess.PIPE)
stdout_git_main_branch, _ = proc.communicate()
return_code = proc.returncode
if return_code != 0:
raise RuntimeError("Couldn't determine newest 'main' git hash")
main_hash = stdout_git_main_branch.decode('utf-8').strip().split()[1]
# Get the merge-base between the newest main and our current rev
command = [ "git", "merge-base", current_hash, main_hash ]
logging.debug("Invoking: %s", " ".join(command))
proc = subprocess.Popen(command, stdout=subprocess.PIPE)
stdout_git_merge_base, _ = proc.communicate()
return_code = proc.returncode
if return_code != 0:
raise RuntimeError("Couldn't determine baseline git hash")
baseline_hash = stdout_git_merge_base.decode('utf-8').strip()
logging.info("Baseline hash: %s", baseline_hash)
else:
baseline_hash = coreclr_args.base_git_hash
if coreclr_args.base_git_hash is None:
# Enumerate the last 20 changes, starting with the baseline, that included JIT and JIT-EE GUID changes.
command = [ "git", "log", "--pretty=format:%H", baseline_hash, "-20", "--", "src/coreclr/jit/*", "src/coreclr/inc/jiteeversionguid.h" ]
logging.debug("Invoking: %s", " ".join(command))
proc = subprocess.Popen(command, stdout=subprocess.PIPE)
stdout_change_list, _ = proc.communicate()
return_code = proc.returncode
change_list_hashes = []
if return_code == 0:
change_list_hashes = stdout_change_list.decode('utf-8').strip().splitlines()
else:
raise RuntimeError("Couldn't determine list of JIT changes starting with baseline hash")View on GitHub (pinned to 290d5ab72c)
Solutions
- Deepen the clone: `git fetch --unshallow` or `git fetch --depth=<large>` then retry.
- Verify both hashes exist locally: `git cat-file -t <hash>`.
- Supply the baseline directly via `--base_git_hash <commit>` to skip merge-base computation.
- If on a divergent fork, rebase onto upstream main to establish shared history.
Example fix
// before # shallow clone missing merge-base object -> raises [182] // after git fetch --unshallow origin && python superpmi.py ... # or python superpmi.py --base_git_hash <known-shared-commit> ...
Defensive patterns
Strategy: validation
Validate before calling
import subprocess
for h in (current_hash, main_hash):
rc = subprocess.run(['git','cat-file','-t',h], cwd=runtime_repo_location).returncode
if rc != 0:
raise SystemExit(f'object {h} missing locally; deepen the clone')
rc = subprocess.run(['git','merge-base',current_hash,main_hash], cwd=runtime_repo_location).returncode
if rc != 0:
raise SystemExit('no merge-base; disjoint history') Type guard
def merge_base_exists(a: str, b: str, cwd: str) -> bool:
import subprocess
return subprocess.run(['git','merge-base',a,b], cwd=cwd,
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).returncode == 0 Try / catch
try:
main(...)
except RuntimeError as e:
if 'baseline git hash' in str(e):
subprocess.run(['git','fetch','--unshallow','origin'], cwd=runtime_repo_location, check=False)
main(...) Prevention
- Avoid shallow clones for diff workflows
- Verify both hashes resolve with git cat-file -t
- Pass --base_git_hash to skip merge-base
When it happens
Trigger: current_hash and main_hash have no common ancestor (disjoint histories), one hash is unknown to the local object store (not fetched), or a hash is malformed.
Common situations: A shallow clone missing the merge-base object; an orphan/branch with no shared history; fetching was interrupted so the object for main_hash is absent; typo in an explicit --git_hash.
Related errors
- Couldn't determine list of JIT changes starting with baselin
- Couldn't determine baseline git hash
- Couldn't determine list of JIT changes starting with baselin
- Couldn't create git diff
- Couldn't determine current git hash
AI-assisted analysis of dotnet/runtime@290d5ab72c (2026-08-06).
Data as JSON: /api/errors/9b3c2c75e3149f8b.
Report an issue: GitHub.