difftastic icon indicating copy to clipboard operation
difftastic copied to clipboard

Support "binary" language override, meaning don't diff

Open gthb opened this issue 7 months ago • 1 comments

Add a binary (or none or no-diff) “language”, which simply means “skip files of this type”, similar to Git's -diff attribute in .gitattributes.

Motivation: my repo contains some test fixtures compressed with brotli, named *.json.br. Git sometimes mistakes them for text, so diffs get useless noise in them — so I put this in fixtures/.gitattributes:

*.br -diff

and that works, git diff (without Difftastic) just says “Binary files differ”.

But Difftastic, via git -c diff.external=difft, still shows the diff, presumably because .gitattributes is not consulted (because it's an external diff).

If Difftastic defined a “binary” language, then I could just use -c external.diff='difft --override="*.br:binary" to tell it what I want.

(Or is there a simple way to achieve this with Difftastic as-is?)

gthb avatar Jun 04 '25 10:06 gthb

Alternatively, in Git I can set up a diff driver with textconv to decompress files for diffing, using this in .gitattributes:

*.br diff=brotli

and this in .gitconfig:

[diff "brotli"]
    textconv = brotli -cd

and then git diff acts on the textconv result so I get diffs despite the compression.

But this also doesn't work with Difftastic configured via external.diff, because Git's external diff option bypasses the diffing machinery, including textconv filters. I imagine it's a bit of a lift to add this to Difftastic directly.

gthb avatar Jun 04 '25 10:06 gthb

Sooner or later I'll need to add support for .gitattributes I think, it's been mentioned a couple of times in other issues.

Having a way for --override to force "binary" does seem reasonable too. Note that difftastic 0.64 is stricter about text encoding, so that might also help it treat brotli compressed files as binary.

Wilfred avatar Jun 20 '25 22:06 Wilfred