Skip to content

fix(diff): decide binary diffs by the diff attribute, as git diff does (ADR 0033) - #16

Merged
ShortArrow merged 2 commits into
mainfrom
feat/gitattributes-binary
Oct 14, 2026
Merged

ShortArrow merged 2 commits into
mainfrom
feat/gitattributes-binary

Conversation

@ShortArrow

@ShortArrow ShortArrow commented Oct 14, 2026 •

Copy link
Copy Markdown
Owner

Commit diffs and untracked files were judged binary by a NUL byte alone, so a file that .gitattributes marks -diff or binary was counted and diffed as text, while git diff shows - -. They now follow the diff attribute first, as ADR 0033 records. Tracked uncommitted files already matched git, because they go through the git CLI.

Where the attributes come from

git diff <commit> <commit> reads the working tree's .gitattributes, info/attributes and the global files, but neither the index nor the compared commits. DiffAttributes::of hands gix an empty index to get the same result. Editing .gitattributes in the working tree therefore changes how past commits show, as it does in git.

The empty index also keeps the cost flat. Loading a 700k-entry index took about 300 ms, and the detail, diff and commit-diff requests each build this lookup.

Where it still differs from git

The ADR lists the remaining gaps: textconv is not run, untracked files over 4 MiB stay binary, and a rename is judged by its new path only. The file list still shows a binary file as +0 −0, which the ROADMAP now tracks.

…s (ADR 0033)

Commit diffs and untracked files judged binary by a NUL byte alone, so files .gitattributes marks -diff or binary were counted and diffed as text.
git diff between commits ignores the index's .gitattributes; loading it also cost about 300 ms per request in a 700k-entry repository.
@ShortArrow
ShortArrow marked this pull request as ready for review October 14, 2026 00:33
@ShortArrow
ShortArrow merged commit 6fceb69 into main Oct 14, 2026
11 checks passed
@ShortArrow
ShortArrow deleted the feat/gitattributes-binary branch October 14, 2026 00:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant