I set *.py diff=python in .git/info/attributes. So Git knows where function boundaries. git diff -W can even make sure the whole function is shown.
But is there a way to limit the output of a git diff to just a particular function (or more than one)?
(Failing that, I guess it’s awk…)
EDIT This would also be useful for git log and git rev-list: don’t show me every commit that modifies views.py, show me commits that modify a certain function in it. (Yes, in an ideal world, views.py wouldn’t be a 2000 line behemoth frequently modified by 8 different developers…)
Ok, thanks to Birei, we have a solution.
Use the awk script in that answer, combined with a bit of bash:
~/scripts/grit:Example usage:
grit funcdiff 009e75 8b7a14 ./staging.py write_uploadedThis could also be added as a git alias in ~/.gitconfig