-
-
Save ruediger/5647207 to your computer and use it in GitHub Desktop.
*.tex diff=tex | |
*.bib diff=bibtex | |
*.c diff=cpp | |
*.h diff=cpp | |
*.c++ diff=cpp | |
*.h++ diff=cpp | |
*.cpp diff=cpp | |
*.hpp diff=cpp | |
*.cc diff=cpp | |
*.hh diff=cpp | |
*.m diff=matlab | |
*.py diff=python | |
*.rb diff=ruby | |
*.php diff=php | |
*.pl diff=perl | |
*.html diff=html | |
*.xhtml diff=html | |
*.f diff=fortran | |
*.lisp diff=lisp | |
*.el diff=lisp | |
*.r diff=rstats | |
*.texi* diff=texinfo | |
*.org diff=orgmode | |
*.rs diff=rust | |
*.pdf diff=pdf | |
*.png diff=exif | |
*.jpg diff=exif | |
*.jpeg diff=exif | |
*.gif diff=exif |
[diff "lisp"] | |
xfuncname = "^(\\(.*)$" | |
# xfuncname = "^(\\((cl-)?def(un|macro|method).*)$" | |
[diff "rstats"] | |
xfuncname = "^([a-zA-z.]+ <- function.*)$" | |
[diff "texinfo"] | |
# from http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=blob;f=.gitattributes;h=c3b2926c78c939d94358cc63d051a70d38cfea5d;hb=HEAD | |
xfuncname = "^@node[ \t][ \t]*\\([^,][^,]*\\)" | |
[diff "orgmode"] | |
xfuncname = "^(\\*+.*)$" | |
#[diff "css"] | |
# xfuncname = "^([a-zA-Z#.@][^\\}]*)$" | |
# xfuncname = "^(.*\\{)$" | |
[diff "rust"] # Thanks to csabahenk | |
xfuncname = "^[ \t]*(pub|)[ \t]*((fn|struct|enum|impl|trait|mod)[^;]*)$" | |
[diff "exif"] | |
binary = true | |
# sudo apt-get install libimage-exiftool-perl | |
textconv = exiftool | |
[diff "pdf"] | |
textconv = pdftotext-stdout | |
# sudo apt-get install pdftotext | |
# copy the following to a script pdftotext-stdout somehwere in $PATH | |
# #!/bin/bash | |
# pdftotext "$@" - |
Suggested improvement:
[diff "rust"]
xfuncname = "^[ \t]*(pub|)[ \t]*((fn|struct|enum|impl|trait|mod)[^;]*)$"
Emacs' git-modes comes with several modes for git including gitattributes-mode
and gitconfig-mode
for editing git attributes and config files.
http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob;f=lib/git-merge-changelog.c
for dealing with ChangeLog merges in git (and hg)
For javascript:
[diff "ecmascript"]
xfuncname = "^((.*function.*)|([ \t]+it\\(.*))$"
Is there c++ xfuncname ?
Further set up for diffing binary documents.
I am searching for patterns for haskell or nix. Can anyone help?
The built-in filter for php did not work well for me.
This works better.
[diff "php"]
xfuncname = "^.*(\\b(((public|protected|private|static)\\s+){1,4}function\\s+[_A-Za-z][_A-Za-z0-9]+\\b\\s*\\()).*$"
Sadly I have minified files on some repos, and the only interesting stuff there is the size:
# .gitattributes
*.min.* diff=minified
[diff "minified"]
textconv = size
#!/bin/bash
file=$1
bits=$(du -b "$file" | cut -f1)
size=$(du -h "$file" | cut -f1)
compressed_size=$( < "$file" gzip | wc -c - | cut -d' ' -f 1 | numfmt --to=iec )
printf "%10sb -> %5s (%4s gziped)\n" "$bits" "$size" "$compressed_size"
Outputs something like:
diff --git c/assets/app.min.js w/assets/app.min.js
index 0c9178d..077b550 100644
--- c/assets/app.min.js
+++ w/assets/app.min.js
@@ -1 +1 @@
- 41907b -> 44K ( 11K gziped)
+ 43031b -> 44K ( 12K gziped)
As of git 2.50, there is now built-in patterns for *ini config files.
Also missing from this list is java and rust (built in now).
See the source for all supported patterns:
https://github.com/git/git/blob/master/userdiff.c
See gitattributes(5) for more information.
Add the stuff in attributes to your
${XDG_CONFIG_HOME:-~/.config}/git/attributes
and the stuff in config to your${XDG_CONFIG_HOME:-~/.config}/git/config
(or~/.gitconfig
)