Skip to content

Commit cff083c

Browse files
gtrrz-victorclaude
andcommitted
Distinguish git diff exit codes in carry-forward detection
Exit 1 means "file is dirty" and should return false immediately, not fall through to raw blob hashing which can re-introduce the autocrlf mismatch. Only fall back to blob hash on actual git failures (exit 128+, timeout). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Entire-Checkpoint: e4ee6688a68c
1 parent 592a460 commit cff083c

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

cmd/entire/cli/strategy/content_overlap.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package strategy
22

33
import (
44
"context"
5+
"errors"
56
"io"
67
"log/slog"
78
"os"
@@ -529,9 +530,15 @@ func workingTreeMatchesCommit(ctx context.Context, worktreeRoot, filePath string
529530
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
530531
defer cancel()
531532
cmd := exec.CommandContext(ctx, "git", "-C", worktreeRoot, "diff", "--exit-code", "--quiet", "--", filePath)
532-
if err := cmd.Run(); err == nil {
533+
err := cmd.Run()
534+
if err == nil {
533535
return true
534536
}
537+
var exitErr *exec.ExitError
538+
if errors.As(err, &exitErr) && exitErr.ExitCode() == 1 {
539+
return false // git says file is dirty
540+
}
541+
// git itself failed (128+, timeout, etc.) — fall back to raw blob hash
535542

536543
absPath := filepath.Join(worktreeRoot, filePath)
537544
diskContent, err := os.ReadFile(absPath) //nolint:gosec // filePath is from git status, not user input

0 commit comments

Comments
 (0)