fix: Capture stderr instead of suppressing in command execution
Several files were setting cmd.Stderr = nil, which hides potentially critical error messages: - prime.go: bd prime, gt mail check, and bd show commands now log stderr on failure for debugging - orphans.go: git fsck now includes stderr in error messages - patrol_helpers.go: bd list/show/catalog commands now log stderr Daemon launch cases (up.go, daemon.go, daemon_check.go) correctly use nil for I/O detachment but now have clarifying comments. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -124,14 +124,19 @@ func findOrphanCommits(repoPath string) ([]OrphanCommit, error) {
|
||||
fsckCmd := exec.Command("git", "fsck", "--unreachable", "--no-reflogs")
|
||||
fsckCmd.Dir = repoPath
|
||||
|
||||
var fsckOut bytes.Buffer
|
||||
var fsckOut, fsckErr bytes.Buffer
|
||||
fsckCmd.Stdout = &fsckOut
|
||||
fsckCmd.Stderr = nil // Ignore warnings
|
||||
fsckCmd.Stderr = &fsckErr
|
||||
|
||||
if err := fsckCmd.Run(); err != nil {
|
||||
// git fsck returns non-zero if there are issues, but we still get output
|
||||
// Only fail if we got no output at all
|
||||
if fsckOut.Len() == 0 {
|
||||
// Include stderr in error message for debugging
|
||||
errMsg := strings.TrimSpace(fsckErr.String())
|
||||
if errMsg != "" {
|
||||
return nil, fmt.Errorf("git fsck failed: %w (%s)", err, errMsg)
|
||||
}
|
||||
return nil, fmt.Errorf("git fsck failed: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user