Skip to content

Commit

Permalink
add .gitattributes rules for rust files
Browse files Browse the repository at this point in the history
Setting `diff=rust` will make git show the current function name in the
hunk headers.

While delta currently removes git's whitespace error markup from diffs
adding the whitespace rules will mean pre-commit hooks that run `git
diff --check` will reject changes with whitespace errors. In order to
get git to print the correct position of the error when there is an
unwanted tab in the indent following a space we need to turn off
`space-before-tab` otherwise the space will be considered to be an error
instead of the tab.

The whitespace rule could perhaps be applied more widely but the
Makefile and example gitcofig have leading tabs so I restricted them to
rust files for now.
  • Loading branch information
phillipwood committed Nov 27, 2022
1 parent afa7a1a commit 9b33424
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.Makefile linguist-language=Makefile
etc/performance/* linguist-vendored
*.rs diff=rust whitespace=tab-in-indent,trailing-space,-space-before-tab eol=lf

0 comments on commit 9b33424

Please sign in to comment.