{"record":{"id":"4f42984053f4cd32","repo":"gastownhall/beads","slug":"reading-git-log-w","errorCode":null,"errorMessage":"reading git log: %w","messagePattern":"reading git log: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/doctor/git.go","lineNumber":903,"sourceCode":"\topenIssues := make(map[string]*OrphanIssue)\n\tfor _, issue := range issues {\n\t\topenIssues[issue.ID] = &OrphanIssue{\n\t\t\tIssueID: issue.ID,\n\t\t\tTitle:   issue.Title,\n\t\t\tStatus:  string(issue.Status),\n\t\t}\n\t}\n\n\tif len(openIssues) == 0 {\n\t\treturn []OrphanIssue{}, nil\n\t}\n\n\t// Get git log\n\tcmd = exec.CommandContext(ctx, \"git\", \"log\", \"--oneline\", \"--all\")\n\tcmd.Dir = gitPath\n\toutput, err := cmd.Output()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"reading git log: %w\", err)\n\t}\n\n\t// Parse commits for issue references\n\t// Match pattern like (bd-xxx) or (bd-xxx.1) including hierarchical IDs\n\tpattern := fmt.Sprintf(`\\(%s-[a-z0-9.]+\\)`, regexp.QuoteMeta(issuePrefix))\n\tre := regexp.MustCompile(pattern)\n\n\tvar orphanedIssues []OrphanIssue\n\tlines := strings.Split(string(output), \"\\n\")\n\n\tfor _, line := range lines {\n\t\tif line == \"\" {\n\t\t\tcontinue\n\t\t}\n\n\t\t// Extract commit hash and message\n\t\tparts := strings.SplitN(line, \" \", 2)\n\t\tif len(parts) < 1 {","sourceCodeStart":885,"sourceCodeEnd":921,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/doctor/git.go#L885-L921","documentation":"FindOrphanedIssues runs `git log --oneline --all` in the discovered git directory to find commit messages that reference issue IDs. When that git command fails, the exec error is wrapped as \"reading git log\". It means git could not produce the log output — typically the path is not a git repository or the object database is damaged.","triggerScenarios":"exec.CommandContext fails executing/running `git log --oneline --all` with cmd.Dir = gitPath: the directory is not a git repo, git exits non-zero due to a corrupt object store, the ctx is cancelled mid-run, or the git binary is unavailable so exec fails to start.","commonSituations":"Running orphan detection on a directory that has .beads but no git history (e.g. shallow/deleted .git); interrupted `git clone` leaving corrupt objects; CI environments where git safe.directory rejects the repo owner; large repos where the command is cancelled by context deadline.","solutions":["Run `git log --oneline --all` manually in the repo to see git's raw error.","Confirm the directory is a git repository: `git -C <dir> rev-parse --git-dir`.","If ownership/safe.directory is the issue, run `git config --global --add safe.directory <path>`.","Repair a corrupt object store with `git fsck` / re-clone the repository.","If context-deadline related, increase the timeout and re-run."],"exampleFix":"// before\n$ bd doctor --check orphans\nreading git log: exit status 128 (fatal: not a git repository)\n\n// after (run inside the actual repo root)\n$ cd /path/to/repo && bd doctor --check orphans\nno orphaned issues found","handlingStrategy":"validation","validationCode":"if err := exec.Command(\"git\", \"-C\", gitPath, \"rev-parse\", \"--git-dir\").Run(); err != nil {\n\treturn fmt.Errorf(\"%s is not a git repository; skipping git-log orphan scan\", gitPath)\n}","typeGuard":null,"tryCatchPattern":"orphaned, err := FindOrphanedIssues(ctx, provider, gitPath)\nif err != nil {\n\tif strings.Contains(err.Error(), \"reading git log\") {\n\t\tlog.Printf(\"git log failed (%v); inspect with `git -C %s log --oneline --all`\", err, gitPath)\n\t}\n\treturn err\n}","preventionTips":["Run orphan detection from the repository root, not a subdirectory or bare data dir.","Add `safe.directory` entries for repos owned by different users (CI/containers).","Run `git fsck` after interrupted clones or forced pulls.","Avoid running with a short context deadline on large histories."],"tags":["git","subprocess","git-log","doctor"],"backgroundTag":"git-command-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}