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

  1. Upgrade git to >= 2.22 which supports `--show-object-format`
  2. Run `git rev-parse --show-object-format` manually to see the raw error
  3. Ensure you are inside a valid git repository
  4. 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

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


AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30). Data as JSON: /api/errors/ed819ca7841d8250. Report an issue: GitHub.