Skip to content

Git diff chip counts lines of untracked files marked -diff in .gitattributes #16611

Open

Description

@Ga-3tan

Pre-submit Checks

Describe the bug

The git diff stats (top-right "± button" and the prompt git chip) count every line of untracked files that .gitattributes marks as -diff (or binary). The Code Review panel correctly excludes them, so the two disagree.

Example: a long, newly generated migration file or log is marked -diff. The Code Review panel shows +28 -0, but the ± button and the prompt chip show +2540 -0.

Cause: for untracked files, the stats read the file from disk and count its lines, which ignores git attributes. The Code Review panel uses git diff, which respects -diff and treats the file as binary (0 lines). Tracked files are not affected, because git diff --numstat already respects attributes.

Possibly related: #12212

To reproduce

  1. In a git repo, add this line to .gitattributes: generated.txt -diff
  2. Create the file without staging it: seq 1 2500 > generated.txt
  3. Look at the ± button in the top-right and the git diff chip in the prompt -> it includes the 2500 lines.
  4. Open the Code Review panel -> generated.txt is excluded from the line count.

Expected behavior

The ± button and the prompt git chip show the same totals as the Code Review panel, excluding untracked files whose diff attribute is unset.

Screenshots, videos, and logs

Image Image

Operating system (OS)

macOS

Operating system and version

macOS 27.0.1

Shell Version

zsh 5.9

Current Warp version

v0.2026.10.14.08.27.stable_02

Regression

No, this bug or issue has existed throughout my experience using Warp

Recent working Warp date

No response

Additional context

No response

Does this block you from using Warp daily?

No

Is this an issue only in Warp?

Yes, I confirmed that this only happens in Warp, not other terminals.

Warp Internal (ignore): linear-label:b9d78064-c89e-4973-b153-5178a31ee54e

None

Activity

  1. warp-for-oss commented on Oct 22, 2026

    @warp-for-oss
    Contributor

    @Ga-3tan

    Here's what I found while triaging this issue:

    The report has enough detail to reproduce, and the behavior matches Warp's current Git diff stats code path. The expected fix is for the prompt/top-right diff stats to respect Git attributes for untracked files the same way the Code Review panel does.

    I've flagged this for the factory auto-implement queue.

    Maintainer details

    I concluded that untracked files marked -diff or binary in .gitattributes are counted by Warp's git diff stats metadata even though the Code Review diff path treats them as binary, causing the prompt/top-right diff counts to disagree with the Code Review panel..

    Triage summary

    This looks like a real bug in the Git diff stats shown outside the Code Review panel. The reporter's explanation matches the current code path: untracked files are enumerated separately from git diff --numstat HEAD, and when there is no numstat row for an untracked file Warp falls back to directly counting working-tree lines.

    Reproducibility

    High. The issue includes minimal reproduction steps, screenshots, and environment details. A local Git check with an untracked generated.txt marked -diff shows that git diff --numstat HEAD produces no entry, while git diff --no-index /dev/null generated.txt treats the file as binary because the diff attribute is unset.

    Likely root cause

    app/src/code_review/diff_state/local.rs computes aggregate diff metadata in diff_metadata_against_head and diff_metadata_against_specific_branch. For untracked files missing from git diff --numstat, it calls num_lines_in_file_if_non_binary, which only inspects file bytes and size and does not consult .gitattributes. app/src/code_review/git_repo_model/local.rs feeds those aggregate stats into GitStatusMetadata, and app/src/context_chips/current_prompt.rs / app/src/context_chips/display_chip.rs render that metadata in the prompt diff chip. The Code Review diff view uses a separate per-file path that runs git diff --no-index for untracked files and therefore treats the -diff file as binary, so the displayed totals can diverge.

    Duplicate check

    I found related open reports about stale or inconsistent Git diff chips, including #12212, #15209, #16319, #9787, #12664, and #12674, but none of the scanned open issues or recently closed issues matched the specific .gitattributes -diff / untracked-file line-count scenario closely enough to mark this as a duplicate under the two-candidate duplicate threshold.

    Factory auto-implementation

    Eligible. The behavior is a client-side bug with high reproducibility, a known root cause, an unambiguous definition of done, and a localized fix path in Git diff metadata handling.

    This is my automated analysis and may be incorrect. A maintainer will verify the details.

    Powered by Oz

  2. added
    agent:bugBugs/regressions. Assigned by Warp triage agent.
    area:code-reviewGit diff views, review UI, review comments, and PR-focused agent flows.
    area:shell-terminalTerminal input/output, shell integration, prompt behavior, and block rendering.
    factory-auto-implementQueued for automated implementation by the Warp factory
    os:macmacOS-specific behavior, regressions, or requests.
    repro:highThe report includes enough evidence that the issue appears highly reproducible.
    triagedIssue has received an initial automated triage pass.
    on Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

agent:bugBugs/regressions. Assigned by Warp triage agent.area:code-reviewGit diff views, review UI, review comments, and PR-focused agent flows.area:shell-terminalTerminal input/output, shell integration, prompt behavior, and block rendering.bugSomething isn't working.factory-auto-implementQueued for automated implementation by the Warp factoryos:macmacOS-specific behavior, regressions, or requests.repro:highThe report includes enough evidence that the issue appears highly reproducible.triagedIssue has received an initial automated triage pass.warp:auto-triage-review

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions