{"record":{"id":"d34b66346397cf69","repo":"JanDeDobbeleer/oh-my-posh","slug":"gitstatus-reftables-head-requires-exec-fallback","errorCode":null,"errorMessage":"gitstatus: reftables HEAD requires exec fallback","messagePattern":"gitstatus: reftables HEAD requires exec fallback","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/gitstatus/refs.go","lineNumber":34,"sourceCode":"\nconst (\n\tbranchRefPrefix = \"ref: refs/heads/\"\n\treftablesHead   = \"ref: refs/heads/.invalid\"\n)\n\n// resolveBranch reads HEAD and resolves it to a commit hash. For a branch\n// checkout it also resolves the configured upstream and, when one exists,\n// the ahead/behind counts. The returned bool is false only for an unborn\n// branch (HEAD points at a branch ref that has never been committed to).\nfunc resolveBranch(opts Options, cfg *ini.File, store *objectStore, result *Result) (plumbing.Hash, bool, error) {\n\tdata, err := os.ReadFile(filepath.Join(opts.WorktreeGitDir, \"HEAD\"))\n\tif err != nil {\n\t\treturn plumbing.ZeroHash, false, err\n\t}\n\n\thead := strings.TrimSpace(string(data))\n\tif head == reftablesHead {\n\t\treturn plumbing.ZeroHash, false, errors.New(\"gitstatus: reftables HEAD requires exec fallback\")\n\t}\n\n\tbranchName, isBranch := strings.CutPrefix(head, branchRefPrefix)\n\tif !isBranch {\n\t\treturn resolveDetached(head, result)\n\t}\n\n\tresult.Ref = branchName\n\n\thash, ok, err := resolveRef(opts.CommonGitDir, \"refs/heads/\"+branchName)\n\tif err != nil {\n\t\treturn plumbing.ZeroHash, false, err\n\t}\n\n\tif !ok {\n\t\t// Unborn branch: no commits yet. Matches porcelain's\n\t\t// `# branch.oid (initial)`. Upstream/ahead-behind are left at their\n\t\t// zero values, same as the exec-git parity path for this case.","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/JanDeDobbeleer/oh-my-posh/blob/0976794618c5ed95de0985dded50de1b4dc914cb/src/gitstatus/refs.go#L16-L52","documentation":"resolveBranch reads HEAD directly from .git/HEAD text. With the new git 'reftable' ref-storage backend, HEAD contains the marker value 'reftablesHead' instead of a normal ref path, which this fast path cannot resolve. The error tells the caller (Load) to fall back to shelling out to git (exec) to resolve the branch.","triggerScenarios":"Opening a repository whose refs are stored in the reftable format (git >= 2.45 repos initialized with reftable storage, e.g. via git init --ref-format=reftable or cloned with gitoxide/Jujutsu defaults).","commonSituations":"Using a repo created by Jujutsu or a recent git with reftable enabled; user upgrades git or migrates refs, and the oh-my-posh gitstatus fast path stops resolving HEAD.","solutions":["Catch this error and fall back to the exec-based branch resolution (git symbolic-ref / git branch --show-current)","If you control the repo, migrate back to files backend: git refs migrate --ref-format=files","Ensure the fallback path in Load is wired so this error surfaces as a normal prompt render, not a hard failure"],"exampleFix":"// before\nhash, isBranch, err := resolveBranch(env, result)\nif err != nil { return err }\n// after\nhash, isBranch, err := resolveBranch(env, result)\nif err != nil {\n    if errors.Is(err, errReftablesHead) {\n        return resolveBranchViaExec(env, result)\n    }\n    return err\n}","handlingStrategy":"fallback","validationCode":"if data, _ := os.ReadFile(gitDir + \"/HEAD\"); strings.TrimSpace(string(data)) == \"ref: reftable\" {\n    // plan for exec-based resolution up front\n}","typeGuard":"func isReftablesHead(head string) bool {\n    return strings.TrimSpace(head) == \"reftable\"\n}","tryCatchPattern":"hash, isBranch, err := resolveBranch(env, result)\nif err != nil {\n    if strings.Contains(err.Error(), \"reftables HEAD\") {\n        return resolveBranchViaExec(env, result)\n    }\n    return err\n}","preventionTips":["Keep the exec fallback wired in Load at all times","Test against repos created with git init --ref-format=reftable","Watch for git version changes in ref-storage defaults"],"tags":["git","reftable","fallback","refs"],"backgroundTag":"unsupported-ref-backend","analyzedSha":"0976794618c5ed95de0985dded50de1b4dc914cb","analyzedAt":"2026-08-31T23:41:19.708Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}