repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

git: map file patterns to the builtin diff drivers

553f4e66a334f3c7afced576fd575b705ed0650b

Oliver Jan Krylow <oliver@bugabinga.net> ·

SSH signature · not checked

Browse filesCompare with HEAD

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.

Changed files (1)

git/gitattributes

Modified
45 45 *.sv merge=mergiraf
46 46 *.svh merge=mergiraf
48 +# Diff drivers select hunk headers, word-diff boundaries, and `grep -W` context.
49 +# Every driver below ships with git except `zig`, which is defined in gitconfig.
50 +# One pattern per line: gitattributes reads the first field as the pattern.
51 +*.adb diff=ada
52 +*.ads diff=ada
53 +*.bash diff=bash
54 +*.bib diff=bibtex
55 +*.c diff=cpp
56 +*.cc diff=cpp
57 +*.cpp diff=cpp
58 +*.cxx diff=cpp
59 +*.h diff=cpp
60 +*.hh diff=cpp
61 +*.hpp diff=cpp
62 +*.hxx diff=cpp
63 +*.cs diff=csharp
64 +*.css diff=css
65 +*.dts diff=dts
66 +*.dtsi diff=dts
67 +*.ex diff=elixir
68 +*.exs diff=elixir
69 +*.f diff=fortran
70 +*.f90 diff=fortran
71 +*.f95 diff=fortran
72 +*.go diff=golang
73 +*.htm diff=html
74 +*.html diff=html
75 +*.xhtml diff=html
76 +*.java diff=java
77 +*.kt diff=kotlin
78 +*.kts diff=kotlin
79 +*.lua diff=lua
80 +*.markdown diff=markdown
81 +*.md diff=markdown
82 +*.mm diff=objc
83 +*.pas diff=pascal
84 +*.pp diff=pascal
85 +*.php diff=php
86 +*.phtml diff=php
87 +*.pl diff=perl
88 +*.pm diff=perl
89 +*.py diff=python
90 +*.R diff=r
91 +*.rb diff=ruby
92 +*.rs diff=rust
93 +*.scm diff=scheme
94 +*.ss diff=scheme
95 +*.cls diff=tex
96 +*.sty diff=tex
97 +*.tex diff=tex
48 98 *.zig diff=zig
49 99 *.zon diff=zig