interpret the gitattributes manual and don't repeat yourself

This commit is contained in:
Aminda Suomalainen 2023-10-15 18:21:01 +03:00
parent c314a3c7d5
commit f0dd5fb1a7
Signed by: Mikaela
SSH Key Fingerprint: SHA256:CXLULpqNBdUKB6E6fLA1b/4SzG0HvKD19PbIePU175Q
2 changed files with 35 additions and 21 deletions

55
.gitattributes vendored
View File

@ -1,29 +1,42 @@
# See https://www.git-scm.com/docs/gitattributes#_effects for more information # If file is text, use lf line-endings and let forges show it in repo
# languages. For more information: `man gitattributes`
* text=auto eol=lf linguist-detectable * text=auto eol=lf linguist-detectable
# Hunk headers for diff shipped with git # Built-in diff patterns (disabled by default). The attribute `diff` implies
# https://www.git-scm.com/docs/gitattributes#_defining_a_custom_hunk_header # `text` and the above attributes are inherited.
*.{sh,bash,zsh} text diff=bash eol=lf *.bibtex diff=bibtex
*.bibtex text diff=bibtex eol=lf *.{c,cpp} diff=cpp
*.cpp text diff=cpp eol=lf *.css diff=css
*.css text diff=css eol=lf *.go diff=golang
*.go text diff=golang eol=lf *.html diff=html
*.html text diff=html eol=lf *.java diff=java
*.java text diff=java eol=lf *.pl diff=perl
*.php diff=php
*.py diff=python
*.rb diff=ruby
*.tex diff=tex
# bash & co aren't often Windows, so alway have lf line-endings regarldess
# of the above. Markdown is also included as I utilise doctoc, which
# requires lf line-endings.
*.{sh,bash,zsh} diff=bash eol=lf
*.{md,markdown} text diff=markdown eol=lf *.{md,markdown} text diff=markdown eol=lf
*.pl text diff=perl eol=lf # While this file is like .gitignore, negative patterns are forbidden and
*.php text diff=php eol=lf # directory/ wouldn't recurse, thus directory/**. Also !attribute would set
*.py text diff=python eol=lf # it back to unset.
*.rb text diff=ruby eol=lf # In this case Windows/** may also contain binary files, thus auto-detection
*.tex text diff=tex eol=lf # is repeated and eol=crlf as it's unlikely to be of use outside of Windows.
Windows/** text=auto eol=crlf
# These files are scary, let's not touch them # Similarly these files are unlikely to be encountered outside of Windows.
# Lockable is provided by git-lfs # The "text" attribute is used as otherwise they rely on auto-detection of
LICENSE text lockable # textness since there is no diff attribute set.
CITATION.cff text lockable
# Windows files even in checkout
# Ref: https://rehansaeed.com/gitattributes-best-practices/#line-endings # Ref: https://rehansaeed.com/gitattributes-best-practices/#line-endings
*.{reg,[rR][eE][gG]} text eol=crlf *.{reg,[rR][eE][gG]} text eol=crlf
*.{bat,[bB][aA][tT]} text eol=crlf *.{bat,[bB][aA][tT]} text eol=crlf
*.{ahk,[aA][hH][kK]} text eol=crlf *.{ahk,[aA][hH][kK]} text eol=crlf
# These files are scary, let's not touch them. The attribute "lockable" is
# provided by git-lfs. https://github.com/git-lfs/git-lfs/wiki/File-Locking
LICENSE text lockable
CITATION.cff text lockable

View File

@ -1 +1,2 @@
* text=auto eol=crlf * text=auto eol=crlf
*.{md,markdown} text eol=lf