dotnet/runtime · error · RuntimeError
Couldn't determine baseline git hash
Error message
Couldn't determine baseline git hash
What it means
Thrown by process_git_hash_arg() when 'git merge-base current_hash main_hash' returns a non-zero exit code. The merge-base identifies the common ancestor between the current commit and the newest remote main commit, which serves as the starting point for searching JIT changes in the rolling build store.
Source
Thrown at src/coreclr/scripts/jitrollingbuild.py:206
# 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)
# 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: {}".format(" ".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")
if len(change_list_hashes) == 0:
raise RuntimeError("No JIT changes found starting with baseline hash")View on GitHub (pinned to 290d5ab72c)
Solutions
- Run 'git merge-base HEAD origin/main' manually to see the exact error.
- If using a shallow clone, deepen it with 'git fetch --unshallow' to ensure the common ancestor is present.
- Pass -git_hash explicitly to bypass auto-detection and avoid the merge-base computation.
- Verify that main_hash (from the previous git branch command) was correctly identified as a valid commit.
Example fix
# before: shallow clone missing merge-base ancestor python jitrollingbuild.py download # after: deepen the clone git fetch --unshallow python jitrollingbuild.py download
Defensive patterns
Strategy: validation
Validate before calling
# Verify merge-base is computable before running auto-detection
import subprocess
result = subprocess.run(['git', 'merge-base', 'HEAD', 'origin/main'], capture_output=True, cwd=repo_path)
if result.returncode != 0:
print('Cannot compute merge-base. Try deepening a shallow clone or pass -git_hash.') Type guard
def can_compute_merge_base(repo_path: str, ref_a: str, ref_b: str) -> bool:
result = subprocess.run(['git', 'merge-base', ref_a, ref_b], capture_output=True, cwd=repo_path)
return result.returncode == 0 Try / catch
try:
process_git_hash_arg(coreclr_args)
except RuntimeError as e:
if 'baseline git hash' in str(e):
logging.error('Merge-base failed. If using shallow clone, run: git fetch --unshallow')
sys.exit(1)
raise Prevention
- Avoid shallow clones for JIT rolling build workflows; use full clones or deepen as needed.
- Run 'git fetch --unshallow' if you encounter merge-base failures on a shallow clone.
- Pass -git_hash to bypass merge-base computation entirely.
When it happens
Trigger: Called after successfully determining current_hash and main_hash. The script runs 'git merge-base <current_hash> <main_hash>'. If git returns non-zero, the RuntimeError is raised at line 206.
Common situations: The current_hash and main_hash have no common ancestor (e.g., the repository was rebased onto an unrelated history, or the commits reference different object stores in a shallow/partial clone). A shallow clone truncated the common ancestor commit. The main_hash was parsed incorrectly from the branch listing output.
Related errors
- Couldn't determine list of JIT changes starting with baselin
- Couldn't determine current git hash
- Couldn't determine newest 'main' git hash
- No JIT changes found starting with baseline hash
- No baseline JIT found
AI-assisted analysis of dotnet/runtime@290d5ab72c (2026-08-06).
Data as JSON: /api/errors/39e59661d996f72d.
Report an issue: GitHub.