mislav/hub · error
Can't load git log %s..%s
Error message
Can't load git log %s..%s
What it means
Log() runs `git log --cherry a...b` to obtain the commit log between two SHAs and returns the raw output as a string. When the git log command fails, it wraps the failure as "Can't load git log <sha1>..<sha2>", meaning the range cannot be computed from the local object store.
Source
Thrown at git/git.go:236
cmd.Stderr = nil
cmd.WithArg("-c").WithArg("log.showSignature=false")
cmd.WithArg("show").WithArg("-s").WithArg("--format=%s%n%+b").WithArg(sha)
output, err := cmd.Output()
return strings.TrimSpace(output), err
}
func Log(sha1, sha2 string) (string, error) {
execCmd := cmd.New("git")
execCmd.WithArg("-c").WithArg("log.showSignature=false").WithArg("log").WithArg("--no-color")
execCmd.WithArg("--format=%h (%aN, %ar)%n%w(78,3,3)%s%n%+b")
execCmd.WithArg("--cherry")
shaRange := fmt.Sprintf("%s...%s", sha1, sha2)
execCmd.WithArg(shaRange)
outputs, err := execCmd.Output()
if err != nil {
return "", fmt.Errorf("Can't load git log %s..%s", sha1, sha2)
}
return outputs, nil
}
func Remotes() ([]string, error) {
remoteCmd := gitCmd("remote", "-v")
remoteCmd.Stderr = nil
output, err := remoteCmd.Output()
return outputLines(output), err
}
func Config(name string) (string, error) {
return gitGetConfig(name)
}
func ConfigAll(name string) ([]string, error) {
mode := "--get-all"View on GitHub (pinned to 5c547ed804)
Solutions
- Fetch full history: git fetch --unshallow (or increase --depth)
- Verify both SHAs exist: git cat-file -e <sha>^{commit}
- Fetch the PR's base ref if working with fork branches
- Check for force-pushes that orphaned the referenced SHAs
Example fix
// before
out, err := git.Log(baseSha, headSha)
// after
if err := run("git", "fetch", "--unshallow"); err != nil {
return err
}
out, err := git.Log(baseSha, headSha) Defensive patterns
Strategy: retry
Validate before calling
for _, s := range []string{sha1, sha2} {
if exec.Command("git", "cat-file", "-e", s+"^{commit}").Run() != nil {
return fmt.Errorf("commit %s not present locally; fetch/unshallow first", s)
}
} Try / catch
out, err := git.Log(sha1, sha2)
if err != nil {
_ = exec.Command("git", "fetch", "--unshallow").Run() // or fetch missing refs
out, err = git.Log(sha1, sha2)
if err != nil {
return fmt.Errorf("git log %s...%s unavailable even after fetch", sha1, sha2)
}
} Prevention
- Avoid --depth 1 clones when log ranges are needed, or unshallow first
- Fetch PR base refs before computing logs
- Re-check SHAs after force-pushes/rebases
- Verify commits exist with git cat-file before log queries
When it happens
Trigger: Calling git.Log(sha1, sha2) (via pullRequest, TestGitLog) with unknown SHAs, SHAs from a shallow clone, or objects pruned by gc — rev-list/log then exits non-zero.
Common situations: Shallow CI checkouts (clone --depth 1) missing history between the SHAs; referencing SHAs from a force-pushed/rebased branch; fork PR base commits not fetched locally.
Related errors
- Aborted: no revision could be determined from '%s'
- Error: %s/%s doesn't have a wiki
- the current branch '%s' doesn't seem pushed to a remote
- the branch to compare '%s' is the default branch
- the branch to compare '%s' is the same as --base
AI-assisted analysis of mislav/hub@5c547ed804 (2026-09-01).
Data as JSON: /api/errors/66a652aff231da01.
Report an issue: GitHub.