How to list all my current TODO messages in a git repository?
I want do add on aragaer's and Kyle's solution:
- use grep config to get your name
- displaying the file name and the line number of the TODO comment
- removing the commit SHA, the author's name and the commit timestamp
git grep -l TODO | xargs -n1 git blame -f -n -w | grep "$(git config user.name)" | grep TODO | sed "s/.\{9\}//" | sed "s/(.*)[[:space:]]*//"
This prints:
Cpp/CoolClass.cpp 123 //TODO: Do we really need this? Cpp/AnotherClass.cpp 42 //TODO: Do we miss something? Java/MyListener.java 23 //TODO: Optimize
You can combine git blame
with grep.
Like this (not the best one, but should work)
git grep -l TODO | xargs -n1 git blame | grep 'Your name' | grep TODO
Improved versions might combine line numbers found by first grep with git blame
's ability to show only given lines.