You can list all modified functions in a revision by using git textconv filters. The idea is to create a specific filter that lists all functions/methods, and for all functions, a checksum of the body. This gives this kind of filtered textconv view:
m() 12
bar() 42
(here m()
is a function signature, 12
is a checksum of its body))
When git diff
uses this filter on the two versions before and after the revision:
- if a function is added, a line is added in the diff
Example: foo is added
m() 12
+ foo() 24
bar() 42
- if a function is modified, the checksum changes, and a line is updated in the diff
Example: the body of foo is modified
m() 12
- foo() 23
+ foo() 24
bar() 42
How to do that?
- Create the filter: java-ls-methods.groovy is an implementation of such a filter using Groovy and Spoon
- Register this filter in git:
git config diff.java-ls-methods.textconv /home/path/to/java-ls-methods.groovy
- Associate this filter with Java files:
echo "*.java diff=java-ls-methods" >> .gitattributes
- Make the diff:
git diff
(diff against last commit) or git diff master
(diff against another branch)
- Once your diff is done, comment the line in
.gitattributes
to go back to a normal diff
Credits: solution inspired from https://stackoverflow.com/a/16929266