git: map file patterns to the builtin diff drivers
553f4e66a334f3c7afced576fd575b705ed0650b
Oliver Jan Krylow <oliver@bugabinga.net> ·
SSH signature · not checked
- Parent 1: 0dc71963dc21
Git compiles 25 language drivers in, but applies none of them without an
attribute. Each driver supplies a funcname regex for hunk headers, a word
boundary regex for word-diff, and the function context used by `grep -W`.
The fallback heuristic often lands on the same hunk header for indented
code, so the visible win is word granularity:
without x = [-"alpha-beta-gamma"-]{+"alpha-delta-gamma"+}
with x = "alpha-[-beta-]{+delta+}-gamma"
One pattern per line, because gitattributes reads the first field as the
pattern and everything after it as attributes. `*.m` is omitted: it is both
Objective-C and MATLAB, and only one driver can win. `*.zig` and `*.zon`
point at the custom driver defined in gitconfig.