gastownhall/beads · error
reading git log: %w
Error message
reading git log: %w
What it means
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.
Source
Thrown at cmd/bd/doctor/git.go:903
openIssues := make(map[string]*OrphanIssue)
for _, issue := range issues {
openIssues[issue.ID] = &OrphanIssue{
IssueID: issue.ID,
Title: issue.Title,
Status: string(issue.Status),
}
}
if len(openIssues) == 0 {
return []OrphanIssue{}, nil
}
// Get git log
cmd = exec.CommandContext(ctx, "git", "log", "--oneline", "--all")
cmd.Dir = gitPath
output, err := cmd.Output()
if err != nil {
return nil, fmt.Errorf("reading git log: %w", err)
}
// Parse commits for issue references
// Match pattern like (bd-xxx) or (bd-xxx.1) including hierarchical IDs
pattern := fmt.Sprintf(`\(%s-[a-z0-9.]+\)`, regexp.QuoteMeta(issuePrefix))
re := regexp.MustCompile(pattern)
var orphanedIssues []OrphanIssue
lines := strings.Split(string(output), "\n")
for _, line := range lines {
if line == "" {
continue
}
// Extract commit hash and message
parts := strings.SplitN(line, " ", 2)
if len(parts) < 1 {View on GitHub (pinned to 71377f2769)
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.
Example fix
// before $ bd doctor --check orphans reading git log: exit status 128 (fatal: not a git repository) // after (run inside the actual repo root) $ cd /path/to/repo && bd doctor --check orphans no orphaned issues found
Defensive patterns
Strategy: validation
Validate before calling
if err := exec.Command("git", "-C", gitPath, "rev-parse", "--git-dir").Run(); err != nil {
return fmt.Errorf("%s is not a git repository; skipping git-log orphan scan", gitPath)
} Try / catch
orphaned, err := FindOrphanedIssues(ctx, provider, gitPath)
if err != nil {
if strings.Contains(err.Error(), "reading git log") {
log.Printf("git log failed (%v); inspect with `git -C %s log --oneline --all`", err, gitPath)
}
return err
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- failed to install hooks: %w
- git config --unset core.hooksPath failed: %w (output: %s)
- not a git repository
- failed to untrack redirect file: %w
- failed to untrack last-touched file: %w
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/4f42984053f4cd32.
Report an issue: GitHub.