(git version 1.6.5.7)
When I run git diff
the output has a nice scope hint after the line numbers for my Python scripts, e.g.:
diff --git a/file.py b/file.py
index 024f5bb..c3b5c56 100644
--- a/file.py
+++ b/file.py
@@ -14,6 +14,8 @@ TITF: Test Infrastructure Tags Format
...
@@ -1507,13 +1533,16 @@ class Tags( object ):
...
Note that the line numbers are followed by TITF: Test Infrastructure Tags Format
and class Tags( object ):
. The first patch applies to module scope and the description TITF: Test Infrastructure Tags Format
is the module's description. The second patch applies to a method of the Tags
class.
Git uses a regular expression to find a suitable line for the hunk headers. Python's is built-in, but you should be able to define your own expression in your ~/.gitconfig:
[diff "python"]
xfuncname = "<regex goes here>"
More about this here.
Edit: The built-in python regex seems to be defined in userdiff.c (line 53), although my regex-fu is not good enough to actually understand exactly what it does...
PATTERNS("python", "^[ \t]*((class|def)[ \t].*)$",
/* -- */
"[a-zA-Z_][a-zA-Z0-9_]*"
"|[-+0-9.e]+[jJlL]?|0[xX]?[0-9a-fA-F]+[lL]?"
"|[-+*/<>%&^|=!]=|//=?|<<=?|>>=?|\\*\\*=?"
"|[^[:space:]|[\x80-\xff]+"),
/* -- */
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With