git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Teach "git diff -p" Python funcname patterns

From
Kirill Smelkov <kirr@mns.spb.ru>
Date
Aug 20, 2008, 15:57 UTC
Message-ID
<1219247827-8742-1-git-send-email-kirr@mns.spb.ru>

Finds classes and functions/methods. The pattern is adapted from the ruby one.

Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
---
 Documentation/gitattributes.txt |    2 ++
 diff.c                          |    1 +
 2 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt
index db16b0c..a8e29d6 100644
--- a/Documentation/gitattributes.txt
+++ b/Documentation/gitattributes.txt
@@ -318,6 +318,8 @@ patterns are available:
 
 - `ruby` suitable for source code in the Ruby language.
 
+- `python` suitable for source code in the Python language.
+
 - `tex` suitable for source code for LaTeX documents.
 
 
diff --git a/diff.c b/diff.c
index 10d5440..91d5a0a 100644
--- a/diff.c
+++ b/diff.c
@@ -1395,6 +1395,7 @@ static struct builtin_funcname_pattern {
 	{ "bibtex", "\\(@[a-zA-Z]\\{1,\\}[ \t]*{\\{0,1\\}[ \t]*[^ \t\"@',\\#}{~%]*\\).*$" },
 	{ "tex", "^\\(\\\\\\(\\(sub\\)*section\\|chapter\\|part\\)\\*\\{0,1\\}{.*\\)$" },
 	{ "ruby", "^\\s*\\(\\(class\\|module\\|def\\)\\s.*\\)$" },
+	{ "python", "^\\s*\\(\\(class\\|def\\)\\s.*\\)$" },
 };
 
 static const char *diff_funcname_pattern(struct diff_filespec *one)
-- 
1.5.6.3
Message 1 of 1 in “Teach "git diff -p" Python funcname patterns”
  1. Teach "git diff -p" Python funcname patternsKirill Smelkov, Aug 20, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.