Teach git diff about BibTeX head hunk patterns
authorGustaf Hendeby <hendeby@isy.liu.se>
Tue, 12 Aug 2008 14:24:26 +0000 (16:24 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 12 Aug 2008 22:43:55 +0000 (15:43 -0700)
All BibTeX entries starts with an @ followed by an entry type.  Since
there are many entry types and own can be defined, the pattern matches
legal entry type names instead of just the default types (which would
be a long list).  The pattern also matches strings and comments since
they will also be useful to position oneself in a bib-file.

Signed-off-by: Gustaf Hendeby <hendeby@isy.liu.se>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/gitattributes.txt
diff.c

index c61a58d8f2e57eb8a193feb8e408e0bee278c918..db16b0ca5b8146361a379de894a1394e0950fd38 100644 (file)
@@ -310,6 +310,8 @@ configuration file (you still need to enable this with the
 attribute mechanism, via `.gitattributes`).  The following built in
 patterns are available:
 
+- `bibtex` suitable for files with BibTeX coded references.
+
 - `java` suitable for source code in the Java lanugage.
 
 - `pascal` suitable for source code in the Pascal/Delphi language.
diff --git a/diff.c b/diff.c
index 6954f992c2f268e2733af1e312a48ac3bc27799b..bf5d5f15a3b54f1e1a0a2068990e899fd869d435 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -1387,6 +1387,7 @@ static struct builtin_funcname_pattern {
                        "\\|"
                        "^\\(.*=[ \t]*\\(class\\|record\\).*\\)$"
                        },
+       { "bibtex", "\\(@[a-zA-Z]\\{1,\\}[ \t]*{\\{0,1\\}[ \t]*[^ \t\"@',\\#}{~%]*\\).*$" },
        { "tex", "^\\(\\\\\\(\\(sub\\)*section\\|chapter\\|part\\)\\*\\{0,1\\}{.*\\)$" },
        { "ruby", "^\\s*\\(\\(class\\|module\\|def\\)\\s.*\\)$" },
 };