dotnet/runtime · error · RuntimeError

Couldn't determine baseline git hash

Error message

Couldn't determine baseline git hash

What it means

Raised by process_git_hash_arg() in jitrollingbuild.py when 'git merge-base <current_hash> <main_hash>' fails. The merge-base command finds the common ancestor between the current commit and the newest main branch commit. This common ancestor is the 'baseline' from which JIT changes are enumerated to find a matching rolling build.

Solutions

  1. Verify both current_hash and main_hash are valid commit hashes by running 'git cat-file -t <hash>'.
  2. If using a shallow clone, run 'git fetch --unshallow' to get full history.
  3. Check 'git merge-base <current> <main>' manually to see the error output.
  4. Pass -git_hash explicitly to skip auto-detection entirely.
  5. Ensure the repository is a proper clone with shared history to the remote main branch.

Example fix

# before
command = ["git", "merge-base", current_hash, main_hash]
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")

# after - capture and surface stderr for diagnosis
command = ["git", "merge-base", current_hash, main_hash]
proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout_git_merge_base, stderr = proc.communicate()
return_code = proc.returncode
if return_code != 0:
    raise RuntimeError(
        "Couldn't determine baseline git hash (current={}, main={}): {}".format(
            current_hash, main_hash, stderr.decode('utf-8').strip()))
Defensive patterns

Strategy: validation

Validate before calling

import subprocess

def can_compute_merge_base(repo_path: str, hash_a: str, hash_b: str) -> bool:
    """Check if git merge-base succeeds for two hashes."""
    if not hash_a or not hash_b:
        return False
    result = subprocess.run(
        ['git', 'merge-base', hash_a, hash_b],
        cwd=repo_path, capture_output=True)
    return result.returncode == 0 and bool(result.stdout.strip())

Type guard

null

Try / catch

try:
    process_git_hash_arg(coreclr_args)
except RuntimeError as e:
    if "baseline git hash" in str(e):
        logging.error(f"{e}. The merge-base between current and main may not exist.")
        logging.error("Try 'git fetch --unshallow' if using a shallow clone.")
    raise

Prevention

When it happens

Trigger: Triggered when git merge-base returns non-zero. This happens if either hash argument is invalid or doesn't exist in the repository, if the two commits have no common ancestor (unrelated histories), or if the repository is in a corrupted state where the object database is inconsistent.

Common situations: The current_hash or main_hash was computed incorrectly (e.g., empty string from a failed parse). The repository has divergent histories (e.g., a fork that doesn't share history with upstream). Git objects are missing due to a partial clone or GC operation. A shallow clone doesn't have enough depth to find the merge-base.

Related errors


AI-assisted analysis of dotnet/runtime@60108ba66e (2026-08-10). Data as JSON: /api/errors/39e59661d996f72d. Report an issue: GitHub.

Appendix: 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 60108ba66e)