mislav/hub · error

Can't load rev-list for %s

Error message

Can't load rev-list for %s

What it means

RefList() runs `git rev-list --cherry-pick --right-only --no-merges a...b` to list commits reachable from b but not a. If rev-list fails (invalid refs, unrelated histories, missing objects), the library wraps it as "Can't load rev-list for <a>...<b>".

Source

Thrown at git/git.go:159

func Ref(ref string) (string, error) {
	parseCmd := gitCmd("rev-parse", "-q", ref)
	parseCmd.Stderr = nil
	output, err := parseCmd.Output()
	if err != nil {
		return "", fmt.Errorf("Unknown revision or path not in the working tree: %s", ref)
	}

	return firstLine(output), nil
}

func RefList(a, b string) ([]string, error) {
	ref := fmt.Sprintf("%s...%s", a, b)
	listCmd := gitCmd("rev-list", "--cherry-pick", "--right-only", "--no-merges", ref)
	listCmd.Stderr = nil
	output, err := listCmd.Output()
	if err != nil {
		return nil, fmt.Errorf("Can't load rev-list for %s", ref)
	}

	return outputLines(output), nil
}

func NewRange(a, b string) (*Range, error) {
	parseCmd := gitCmd("rev-parse", "-q", a, b)
	parseCmd.Stderr = nil
	output, err := parseCmd.Output()
	if err != nil {
		return nil, err
	}

	lines := outputLines(output)
	if len(lines) != 2 {
		return nil, fmt.Errorf("Can't parse range %s..%s", a, b)
	}
	return &Range{lines[0], lines[1]}, nil

View on GitHub (pinned to 5c547ed804)

Solutions

  1. Verify both refs resolve: git rev-parse <a> <b>
  2. Fetch the base branch first (git fetch origin <base>)
  3. If histories are unrelated, use an explicit merge-base or correct base ref
  4. Deepen a shallow clone: git fetch --unshallow

Example fix

// before
list, err := git.RefList("main", "feature")
// after
if _, err := git.Ref("main"); err != nil {
    return fmt.Errorf("base ref %q not found; fetch first", "main")
}
list, err := git.RefList("main", "feature")
Defensive patterns

Strategy: validation

Validate before calling

for _, r := range []string{a, b} {
    if exec.Command("git", "rev-parse", "-q", "--verify", r).Run() != nil {
        return fmt.Errorf("ref %q does not exist; fetch before comparing", r)
    }
}

Try / catch

list, err := git.RefList(a, b)
if err != nil {
    return fmt.Errorf("cannot compute %s...%s; fetch base and ensure shared history", a, b)
}

Prevention

When it happens

Trigger: Calling git.RefList(a, b) (via pullRequest, TestGitRefList) where a or b are unknown refs, or the symmetric range a...b cannot be computed (unrelated histories, shallow clone missing objects).

Common situations: Base branch name typo; comparing branches across repos with no common ancestor; shallow clones lacking the merge-base; fork PRs whose base commit isn't fetched.

Related errors


AI-assisted analysis of mislav/hub@5c547ed804 (2026-09-01). Data as JSON: /api/errors/ba14d783a07ff4be. Report an issue: GitHub.