#16612

Respect .gitattributes -diff for untracked files in git diff stats

DraftGa-3tanwants to merge intofrom

Description

Untracked files marked -diff (or binary) in .gitattributes were counted line by line in the git diff stats (prompt git diff chip and the top-right ± button), while the Code Review panel treated them as binary. In my case, a long generated migration file made the chip show +2540 while the Code Review panel showed +28.

Cause: for untracked files, git diff --numstat has no row, so the stats fall back to reading the file from disk and counting lines. That fallback ignores git attributes. The Code Review panel uses git diff --no-index, which respects them.

Fix:

  • New helper paths_with_diff_attr_unset (app/src/util/git.rs) runs git check-attr -z diff on the untracked paths (chunked) and returns those with diff unset.
  • Every place that counts untracked lines skips those paths:
    • diff_metadata_against_head and diff_metadata_against_specific_branch (app/src/code_review/diff_state/local.rs) → prompt chip, ± button, branch stats.
    • get_repo_git_summary and get_file_change_entries (app/src/util/git.rs) → repos menu, per-file lists.
    • get_diff_for_commit_message → content of -diff untracked files is no longer sent for AI commit messages.
  • Untracked paths in app/src/util/git.rs are now read with ls-files -z, so non-ASCII names are not C-quoted and match check-attr output.

Known limit: a custom diff driver with binary = true in git config (diff=<driver>) is not detected; only an unset diff attribute is.

Linked Issue

Fixes #16611

  • The linked issue is labeled ready-to-spec or ready-to-implement.
  • Where appropriate, screenshots or a short video of the implementation are included below (especially for user-visible or UI changes).

Testing

  • Added repo_git_summary_skips_untracked_files_with_diff_unset in app/src/util/git_tests.rs: an untracked *.sql file marked -diff is not counted.

  • cargo nextest run -p warp --lib util::git passes.

  • cargo clippy -p warp --bin warp-oss --tests -- -D warnings passes.

  • ./script/presubmit: format, clippy, clang-format and wgslfmt pass. 13027/13036 tests pass; the 9 failures are environment-only and unrelated to this change:

    • 6 SSH integration tests (test_ssh_*, test_cloud_agent_shell_respawn) need Warp's internal GCP IAP access (not authorized).
    • 3 remote_server::...::remote_move_* tests fail only under the full parallel run (they receive a RemoteAgentContextSnapshot built from local ~/.claude/skills); they pass when run on their own.
  • Manually tested with ./script/run on macOS: with an untracked migration file marked -diff, the prompt chip and the ± button now match the Code Review panel.

  • I have manually tested my changes locally with ./script/run

Screenshots / Videos

Before (± button and prompt chip count the -diff file; Code Review panel does not):

After (counts exclude the -diff file):

Agent Mode

  • Warp Agent Mode - This PR was created via Warp's AI Agent Mode

CHANGELOG-BUG-FIX: Git diff stats in the prompt chip and the top-right diff button no longer count lines of untracked files marked -diff or binary in .gitattributes.

🤖 Generated with Claude Code

Activity

5
cla-bot[bot]8d ago

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @Ga-3tan on file. In order for us to review and merge your code, each contributor must visit https://cla.warp.dev to read and agree to our CLA. Once you have done so, please comment @cla-bot check to trigger another check.

Ga-3tan8d ago

@cla-bot check

cla-bot[bot]8d ago

The cla-bot has been summoned, and re-checked this pull request!

This pull request is a draft

Merging is unavailable until it is marked ready for review.