{"record":{"id":"9b3c2c75e3149f8b","repo":"dotnet/runtime","slug":"couldn-t-determine-baseline-git-hash-9b3c2c","errorCode":null,"errorMessage":"Couldn't determine baseline git hash","messagePattern":"Couldn't determine baseline git hash","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/coreclr/scripts/superpmi.py","lineNumber":4892,"sourceCode":"            # First find the newest hash for any branch matching */main.\n            command = [ \"git\", \"branch\", \"-r\", \"--sort=-committerdate\", \"-v\", \"--list\", \"*/main\" ]\n            logging.debug(\"Invoking: %s\", \" \".join(command))\n            proc = subprocess.Popen(command, stdout=subprocess.PIPE)\n            stdout_git_main_branch, _ = proc.communicate()\n            return_code = proc.returncode\n            if return_code != 0:\n                raise RuntimeError(\"Couldn't determine newest 'main' git hash\")\n\n            main_hash = stdout_git_main_branch.decode('utf-8').strip().split()[1]\n\n            # Get the merge-base between the newest main and our current rev\n            command = [ \"git\", \"merge-base\", current_hash, main_hash ]\n            logging.debug(\"Invoking: %s\", \" \".join(command))\n            proc = subprocess.Popen(command, stdout=subprocess.PIPE)\n            stdout_git_merge_base, _ = proc.communicate()\n            return_code = proc.returncode\n            if return_code != 0:\n                raise RuntimeError(\"Couldn't determine baseline git hash\")\n\n            baseline_hash = stdout_git_merge_base.decode('utf-8').strip()\n            logging.info(\"Baseline hash: %s\", baseline_hash)\n        else:\n            baseline_hash = coreclr_args.base_git_hash\n\n        if coreclr_args.base_git_hash is None:\n            # Enumerate the last 20 changes, starting with the baseline, that included JIT and JIT-EE GUID changes.\n            command = [ \"git\", \"log\", \"--pretty=format:%H\", baseline_hash, \"-20\", \"--\", \"src/coreclr/jit/*\", \"src/coreclr/inc/jiteeversionguid.h\" ]\n            logging.debug(\"Invoking: %s\", \" \".join(command))\n            proc = subprocess.Popen(command, stdout=subprocess.PIPE)\n            stdout_change_list, _ = proc.communicate()\n            return_code = proc.returncode\n            change_list_hashes = []\n            if return_code == 0:\n                change_list_hashes = stdout_change_list.decode('utf-8').strip().splitlines()\n            else:\n                raise RuntimeError(\"Couldn't determine list of JIT changes starting with baseline hash\")","sourceCodeStart":4874,"sourceCodeEnd":4910,"githubUrl":"https://github.com/dotnet/runtime/blob/290d5ab72cc1102813fbc0406fb186ceadabc340/src/coreclr/scripts/superpmi.py#L4874-L4910","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\n# shallow clone missing merge-base object -> raises [182]\n// after\ngit fetch --unshallow origin && python superpmi.py ...\n# or\npython superpmi.py --base_git_hash <known-shared-commit> ...","handlingStrategy":"validation","validationCode":"import subprocess\nfor h in (current_hash, main_hash):\n    rc = subprocess.run(['git','cat-file','-t',h], cwd=runtime_repo_location).returncode\n    if rc != 0:\n        raise SystemExit(f'object {h} missing locally; deepen the clone')\nrc = subprocess.run(['git','merge-base',current_hash,main_hash], cwd=runtime_repo_location).returncode\nif rc != 0:\n    raise SystemExit('no merge-base; disjoint history')","typeGuard":"def merge_base_exists(a: str, b: str, cwd: str) -> bool:\n    import subprocess\n    return subprocess.run(['git','merge-base',a,b], cwd=cwd,\n                          stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).returncode == 0","tryCatchPattern":"try:\n    main(...)\nexcept RuntimeError as e:\n    if 'baseline git hash' in str(e):\n        subprocess.run(['git','fetch','--unshallow','origin'], cwd=runtime_repo_location, check=False)\n        main(...)","preventionTips":["Avoid shallow clones for diff workflows","Verify both hashes resolve with git cat-file -t","Pass --base_git_hash to skip merge-base"],"tags":["git","superpmi","shallow-clone"],"analyzedSha":"290d5ab72cc1102813fbc0406fb186ceadabc340","analyzedAt":"2026-08-06T19:57:01.276Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}