{"record":{"id":"a7902a199e75dad0","repo":"pypa/pip","slug":"unexpected-show-ref-line-line-r","errorCode":null,"errorMessage":"unexpected show-ref line: {line!r}","messagePattern":"unexpected show-ref line: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/pip/_internal/vcs/git.py","lineNumber":173,"sourceCode":"            cwd=dest,\n            show_stdout=False,\n            stdout_only=True,\n            on_returncode=\"ignore\",\n        )\n        refs = {}\n        # NOTE: We do not use splitlines here since that would split on other\n        #       unicode separators, which can be maliciously used to install a\n        #       different revision.\n        for line in output.strip().split(\"\\n\"):\n            line = line.rstrip(\"\\r\")\n            if not line:\n                continue\n            try:\n                ref_sha, ref_name = line.split(\" \", maxsplit=2)\n            except ValueError:\n                # Include the offending line to simplify troubleshooting if\n                # this error ever occurs.\n                raise ValueError(f\"unexpected show-ref line: {line!r}\")\n\n            refs[ref_name] = ref_sha\n\n        branch_ref = f\"refs/remotes/origin/{rev}\"\n        tag_ref = f\"refs/tags/{rev}\"\n\n        sha = refs.get(branch_ref)\n        if sha is not None:\n            return (sha, True)\n\n        sha = refs.get(tag_ref)\n\n        return (sha, False)\n\n    @classmethod\n    def _should_fetch(cls, dest: str, rev: str) -> bool:\n        \"\"\"\n        Return true if rev is a ref or is a commit that we don't have locally.","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/pypa/pip/blob/f399c3718970b1b0e2478dac5296eb62679a9b86/src/pip/_internal/vcs/git.py#L155-L191","documentation":"Raised by Git.get_revision_sha() when a line of 'git show-ref' output cannot be split into exactly two whitespace-separated parts (ref_sha and ref_name). This is an internal parsing error indicating the git command produced output in an unexpected format.","triggerScenarios":"Calling get_revision_sha(dest, rev) where the 'git show-ref <rev>' output contains a line that does not match the expected '<sha> <refname>' two-token format. The ValueError is raised at line 173 after a failed str.split with maxsplit=2.","commonSituations":"A git version that changes the show-ref output format (extremely rare). A corrupted or unusual git state. A ref name containing unusual characters. Essentially an unexpected internal state — this should not occur under normal git versions.","solutions":["Check your git version: 'git --version' — upgrade if significantly outdated","Run 'git show-ref <rev>' manually in the repo to inspect the output format","Clean the git repo state: 'git gc' or re-clone the repository","Report a pip bug with the git version and the show-ref output if it persists"],"exampleFix":"// before\npip install git+https://example.com/repo.git@some-ref\n// after\n# inspect the git output manually\ncd /tmp/clone && git show-ref some-ref\ngit --version  # ensure a supported git version\n# re-clone cleanly if the repo state is corrupt\npip install --force-reinstall git+https://example.com/repo.git@some-ref","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"def is_valid_show_ref_line(line: str) -> bool:\n    parts = line.split(' ')\n    return len(parts) == 2 and all(parts)","tryCatchPattern":"try:\n    sha, is_branch = Git.get_revision_sha(dest, rev)\nexcept ValueError as e:\n    if 'unexpected show-ref line' in str(e):\n        # inspect git version and output, report as environment issue\n        logger.error('git show-ref output unexpected: %s', e)\n        raise EnvironmentError(f'unsupported git version or corrupt repo: {e}')\n    raise","preventionTips":["Use a supported, up-to-date git version","Keep the git repo clean ('git gc')","Re-clone if the repository state is corrupt","Report persistent issues as a pip bug with git version details"],"tags":["git","vcs","parsing","show-ref","internal"],"backgroundTag":null,"analyzedSha":"f399c3718970b1b0e2478dac5296eb62679a9b86","analyzedAt":"2026-08-08T23:01:42.227Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}