Teach "git diff -p" Python funcname patterns
authorKirill Smelkov <kirr@mns.spb.ru>
Wed, 20 Aug 2008 15:57:07 +0000 (19:57 +0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 21 Aug 2008 06:53:33 +0000 (23:53 -0700)
Find classes, functions, and methods definitions.

Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/gitattributes.txt
diff.c

index db16b0ca5b8146361a379de894a1394e0950fd38..9279df5349889a7e6d133b7503c7ef3e8f492364 100644 (file)
@@ -316,6 +316,8 @@ patterns are available:
 
 - `pascal` suitable for source code in the Pascal/Delphi language.
 
+- `python` suitable for source code in the Python language.
+
 - `ruby` suitable for source code in the Ruby language.
 
 - `tex` suitable for source code for LaTeX documents.
diff --git a/diff.c b/diff.c
index 5923fe281b6ab421f785a1d47afd6dee5711e52d..22154164413130bb69ce34327545973ea002b9cd 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -1394,6 +1394,7 @@ static struct builtin_funcname_pattern {
                        },
        { "bibtex", "\\(@[a-zA-Z]\\{1,\\}[ \t]*{\\{0,1\\}[ \t]*[^ \t\"@',\\#}{~%]*\\).*$" },
        { "tex", "^\\(\\\\\\(\\(sub\\)*section\\|chapter\\|part\\)\\*\\{0,1\\}{.*\\)$" },
+       { "python", "^\\s*\\(\\(class\\|def\\)\\s.*\\)$" },
        { "ruby", "^\\s*\\(\\(class\\|module\\|def\\)\\s.*\\)$" },
 };