How does git-diff generate hunk descriptions?

Posted by RobM on Stack Overflow See other posts from Stack Overflow or by RobM
Published on 2010-05-06T17:24:50Z Indexed on 2010/05/06 17:28 UTC
Read the original article Hit count: 277

Filed under:
|
|

(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.

  1. How does git generate these descriptions?
  2. How can I tweak them to show the method name that the patch applies to?

© Stack Overflow or respective owner

Related posts about git

Related posts about diff