{"record":{"id":"e16ce8481b93f76c","repo":"plandex-ai/plandex","slug":"error-getting-git-history-for-dir-s-err-v","errorCode":null,"errorMessage":"error getting git history for dir: %s, err: %v","messagePattern":"error getting git history for dir: (.+?), err: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/server/db/git.go","lineNumber":476,"sourceCode":"}\n\nfunc gitRewindToSha(repoDir, sha string) error {\n\tres, err := exec.Command(\"git\", \"-C\", repoDir, \"reset\", \"--hard\", sha).CombinedOutput()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error executing git reset for dir: %s, sha: %s, err: %v, output: %s\", repoDir, sha, err, string(res))\n\t}\n\n\treturn nil\n}\n\nfunc getLatestCommit(dir string) (sha, body string, err error) {\n\tvar out bytes.Buffer\n\tcmd := exec.Command(\"git\", \"log\", \"--pretty=%h@@|@@%at@@|@@%B@>>>@\")\n\tcmd.Dir = dir\n\tcmd.Stdout = &out\n\terr = cmd.Run()\n\tif err != nil {\n\t\treturn \"\", \"\", fmt.Errorf(\"error getting git history for dir: %s, err: %v\", dir, err)\n\t}\n\n\t// Process the log output to get it in the desired format.\n\thistory := processGitHistoryOutput(strings.TrimSpace(out.String()))\n\n\tfirst := history[0]\n\n\tsha = first[0]\n\tbody = first[1]\n\n\treturn sha, body, nil\n}\n\nfunc getGitCommitHistory(dir string) (body string, shas []string, err error) {\n\tvar out bytes.Buffer\n\tcmd := exec.Command(\"git\", \"log\", \"--pretty=%h@@|@@%at@@|@@%B@>>>@\")\n\tcmd.Dir = dir\n\tcmd.Stdout = &out","sourceCodeStart":458,"sourceCodeEnd":494,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/db/git.go#L458-L494","documentation":"getLatestCommit: `git log --pretty=...` in the plan repo directory failed, so the latest commit sha/message cannot be read. Usually means the directory is not a git repo, has no commits, or git itself errored.","triggerScenarios":"Thrown at app/server/db/git.go:476 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Confirm the directory contains an initialized git repo with commits","Run git log manually in that dir to reproduce","Check repo ownership/safe.directory settings"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}