gastownhall/beads · error
failed to determine repository object format: %w
Error message
failed to determine repository object format: %w
What it means
bd determines the repository's hash length by running `git rev-parse --show-object-format` (sha1 → 40 hex chars, sha256 → 64). If that command fails, the error is wrapped so the caller knows full-OID detection could not be performed.
Source
Thrown at cmd/bd/worktree_cmd.go:1834
matchSet[ref] = struct{}{}
}
}
matches := make([]string, 0, len(matchSet))
for ref := range matchSet {
matches = append(matches, ref)
}
sort.Strings(matches)
return matches, nil
}
func repositoryObjectIDLength(
ctx context.Context,
git *worktreeRemovalGit,
executionRoot string,
) (int, error) {
output, err := git.output(ctx, executionRoot, "rev-parse", "--show-object-format")
if err != nil {
return 0, fmt.Errorf("failed to determine repository object format: %w", err)
}
switch strings.TrimSpace(string(output)) {
case "sha1":
return 40, nil
case "sha256":
return 64, nil
default:
return 0, fmt.Errorf("unsupported git object format %q", strings.TrimSpace(string(output)))
}
}
func isHexObjectID(value string, length int) bool {
if len(value) != length {
return false
}
for _, character := range value {
if character >= '0' && character <= '9' ||
character >= 'a' && character <= 'f' ||View on GitHub (pinned to 71377f2769)
Solutions
- Upgrade git to >= 2.22 which supports `--show-object-format`
- Run `git rev-parse --show-object-format` manually to see the raw error
- Ensure you are inside a valid git repository
- Check `git --version` and PATH configuration
Example fix
// before: git 2.17 (flag unsupported) // after git --version # ensure >= 2.22 brew upgrade git # or apt-get install -y git
Defensive patterns
Strategy: retry
Validate before calling
// shell pre-check git rev-parse --show-object-format >/dev/null 2>&1 || echo "git too old (<2.22) or not in a repo"
Try / catch
if err != nil && strings.Contains(err.Error(), "object format") {
// upgrade git >= 2.22, then retry the command
} Prevention
- Require git >= 2.22 in your environment/setup docs
- Verify `git rev-parse --show-object-format` works in CI before invoking bd
- Keep git installations current on macOS/Linux images
When it happens
Trigger: `git rev-parse --show-object-format` exits non-zero — very old git (< 2.22) that lacks the flag, running outside a repository, or a broken git install.
Common situations: Old git versions on macOS/CentOS that predate `--show-object-format`; bare or corrupted repo; git not on PATH.
Related errors
- failed to install hooks: %w
- git config --unset core.hooksPath failed: %w (output: %s)
- reading git log: %w
- git ls-remote %s failed: %s: %w
- git push (delete %s) failed: %s: %w
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/ed819ca7841d8250.
Report an issue: GitHub.