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 db16b0c..9279df5 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 5923fe2..2215416 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.*\\)$" },
 };