{"record":{"id":"18f7fd876206515c","repo":"Jguer/yay","slug":"s-w","errorCode":null,"errorMessage":"%s%w","messagePattern":"%s%w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/menus/diff_menu.go","lineNumber":95,"sourceCode":"\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\targs := []string{\"--no-pager\", \"diff\"}\n\t\tif text.UseColor {\n\t\t\targs = append(args, \"--color=always\")\n\t\t} else {\n\t\t\targs = append(args, \"--color=never\")\n\t\t}\n\n\t\targs = append(args,\n\t\t\tstart+\"..HEAD@{upstream}\", \"--src-prefix\",\n\t\t\tdir+\"/\", \"--dst-prefix\", dir+\"/\", \"--\", \".\", \":(exclude).SRCINFO\",\n\t\t)\n\n\t\tstdout, stderr, err := cmdBuilder.Capture(cmdBuilder.BuildGitCmd(ctx, dir, args...))\n\t\tif err != nil {\n\t\t\terrs = append(errs, fmt.Errorf(\"%s%w\", stderr, err))\n\n\t\t\tcontinue\n\t\t}\n\n\t\tif stdout == \"\" {\n\t\t\tcontinue\n\t\t}\n\n\t\tbuf.WriteString(logger.SprintOperationInfo(gotext.Get(\"Showing diff for %s\", text.Bold(pkg))))\n\t\tbuf.WriteByte('\\n')\n\t\tbuf.WriteString(stdout)\n\t\tbuf.WriteString(\"\\n\\n\")\n\t}\n\n\treturn buf.String(), errs\n}\n\n// Check whether or not a diff exists between the last reviewed diff and","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/Jguer/yay/blob/328f4b4939fb35f38c2f7c7ce3b8638a839bafa5/pkg/menus/diff_menu.go#L77-L113","documentation":"collectPkgbuildDiffs runs `git diff start..HEAD@{upstream}` inside each cloned AUR repo (excluding .SRCINFO) via cmdBuilder.Capture. When git exits non-zero, the captured stderr is prepended to the underlying error and accumulated into errs (%s%w). The overall diff flow then reports these per-package failures, so one bad clone can fail the whole review list.","triggerScenarios":"The git diff command fails for a package's clone directory: repo has no upstream configured (or upstream ref missing), .git corrupted, the clone was made by an older layout, or git itself errors on revision 'HEAD@{upstream}'.","commonSituations":"Interrupted/cloned-then-pruned AUR checkouts where origin/upstream is unset; user manually moved the repo dir; git version/config (safe.directory) refusing to operate on a root-owned clone; partial clone after network failure.","solutions":["Fix the clone: cd <builddir>/<pkg> && git remote set-url origin <AUR ssh/https URL> && git fetch origin, ensuring HEAD has an upstream (git branch -u origin/master)","Re-clone the affected package: remove the package dir in BuildDir and rerun the diff/update so yay re-fetches it","Check ownership/permissions (git safe.directory) if clones were created by root: chown -R $USER <builddir>/<pkg>","Inspect stderr in the error message — it names the exact git failure; address that (corrupt .git → rm -rf and re-clone)"],"exampleFix":"// before\nstdout, stderr, err := cmdBuilder.Capture(cmdBuilder.BuildGitCmd(ctx, dir, args...))\nif err != nil { errs = append(errs, fmt.Errorf(\"%s%w\", stderr, err)); continue }\n// after\n// pre-flight per repo so diff never fails on a broken clone:\ncmd := exec.Command(\"git\", \"-C\", dir, \"rev-parse\", \"--abbrev-ref\", \"HEAD@{upstream}\")\nif err := cmd.Run(); err != nil {\n    _ = os.RemoveAll(dir) // broken clone (no upstream/corrupt) — yay will re-clone\n}\nstdout, stderr, err := cmdBuilder.Capture(cmdBuilder.BuildGitCmd(ctx, dir, args...))","handlingStrategy":"validation","validationCode":"// before diffing, ensure each clone has a valid upstream\nfor _, dir := range pkgDirs {\n    cmd := exec.Command(\"git\", \"-C\", dir, \"rev-parse\", \"--abbrev-ref\", \"--verify\", \"HEAD@{upstream}\")\n    if err := cmd.Run(); err != nil {\n        // missing/corrupt upstream: re-clone the package dir\n        os.RemoveAll(dir)\n    }\n}","typeGuard":null,"tryCatchPattern":"stdout, stderr, err := cmdBuilder.Capture(cmdBuilder.BuildGitCmd(ctx, dir, args...))\nif err != nil {\n    if isGitBroken(stderr) { // e.g. 'no upstream configured', 'not a git repository'\n        os.RemoveAll(dir); return reCloneAndDiff(pkg)\n    }\n    errs = append(errs, fmt.Errorf(\"%s%w\", stderr, err))\n    continue\n}","preventionTips":["Never move or manually edit clones under BuildDir; let yay manage them","Keep clone ownership consistent — avoid root-created clones then running as user (git safe.directory)","After interrupted updates, re-clone the affected package instead of reusing a half-fetched repo","Run `git fetch` and check `git status` if diffs suddenly error for one package"],"tags":["git","aur","pkgbuild"],"backgroundTag":"git-command-failed","analyzedSha":"328f4b4939fb35f38c2f7c7ce3b8638a839bafa5","analyzedAt":"2026-09-07T16:45:12.608Z","contentChangedAt":"2026-09-07T16:45:12.608Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}