Jguer/yay · error
%s %w
Error message
%s %w
What it means
getLastSeenHash wraps the failure of `git rev-parse <gitDiffRefName>` by concatenating git's stderr with the exec error via fmt.Errorf("%s %w", stderr, err). This ref stores the commit hash last shown to the user for PKGBUILD diffs; when it cannot be resolved the diff menu cannot compute what changed. The %w wrap keeps the underlying exec error inspectable.
Solutions
- Check the ref exists right before use: git rev-parse refs/has-been-reviewed in the package dir
- Recreate the ref from current HEAD: git update-ref refs/has-been-reviewed HEAD
- Re-clone the AUR package if the repository is corrupt
- Verify git is installed and on PATH (git --version)
Example fix
// before
return "", fmt.Errorf("%s %w", stderr, err)
// after
return "", fmt.Errorf("resolving last-seen ref %q in %s: %s: %w", gitDiffRefName, dir, stderr, err) Defensive patterns
Strategy: try-catch
Validate before calling
out, err := exec.Command("git", "-C", dir, "rev-parse", "--verify", ref).Output()
if err != nil { /* ref missing: skip diff or recreate */ } Type guard
func refExists(dir, ref string) bool {
return exec.Command("git", "-C", dir, "rev-parse", "--verify", "--quiet", ref).Run() == nil
} Try / catch
hash, err := getLastSeenHash(ctx, cb, dir)
if err != nil {
log.Printf("no last-seen hash for %s: %v; showing full diff", dir, err)
return "", nil // fall back to full diff
} Prevention
- Use `git rev-parse --verify --quiet <ref>` as an existence check instead of a separate boolean helper
- Hold the package dir stable (no re-download) while diffing
- Log stderr from Capture at debug level to catch transient git failures
- Serialize diff sessions to avoid concurrent ref pruning
When it happens
Trigger: getLastSeenHash runs when gitHasLastSeenRef says the ref exists, but the subsequent `git rev-parse` of that ref fails (ref deleted between the check and the call, corrupted ref file, git repo removed mid-operation, git binary unavailable).
Common situations: Race where another yakuake/instance or `git gc` prunes refs/has-been-reviewed while the diff menu runs; package dir replaced by a fresh non-git download between check and read; PATH lacking git so cmdBuilder.Capture fails to exec.
Understand the failure class
Background: "git command failed": what it means when a tool shells out to git and git exits non-zero — this error's family across 21 libraries.
Related errors
AI-assisted analysis of Jguer/yay@328f4b4939 (2026-09-07).
Data as JSON: /api/errors/25f504c8a3b72dcb.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/menus/diff_menu.go:152
// Return whether or not we have reviewed a diff yet. It checks for the existence of
// AUR_SEEN in the git ref-list.
func gitHasLastSeenRef(ctx context.Context, cmdBuilder exe.ICmdBuilder, dir string) bool {
_, _, err := cmdBuilder.Capture(
cmdBuilder.BuildGitCmd(ctx,
dir, "rev-parse", "--quiet", "--verify", gitDiffRefName))
return err == nil
}
// Returns the last reviewed hash. If AUR_SEEN exists it will return this hash.
// If it does not it will return empty tree as no diff have been reviewed yet.
func getLastSeenHash(ctx context.Context, cmdBuilder exe.ICmdBuilder, dir string) (string, error) {
if gitHasLastSeenRef(ctx, cmdBuilder, dir) {
stdout, stderr, err := cmdBuilder.Capture(
cmdBuilder.BuildGitCmd(ctx,
dir, "rev-parse", gitDiffRefName))
if err != nil {
return "", fmt.Errorf("%s %w", stderr, err)
}
lines := strings.Split(stdout, "\n")
return lines[0], nil
}
return gitEmptyTree, nil
}
// Update the AUR_SEEN ref to HEAD. We use this ref to determine which diff were
// reviewed by the user.
func gitUpdateSeenRef(ctx context.Context, cmdBuilder exe.ICmdBuilder, dir string) error {
_, stderr, err := cmdBuilder.Capture(
cmdBuilder.BuildGitCmd(ctx,
dir, "update-ref", gitDiffRefName, "HEAD"))
if err != nil {
return fmt.Errorf("%s %w", stderr, err)View on GitHub (pinned to 328f4b4939)