How to print all TODO comments I ever added or edited during any git commit
-
21-12-2019 - |
Question
How can I list all TODO comments I ever added or edited within all commits of a git versioned project? I do not want to see everyone else's TODO comments.
The output should print all lines actually containing my TODO comments:
\\TODO: This should be changed to something else
\\TODO I guess the bug hides here
\\ TODO I need to do something here
I do not want to just list the commits themselves as git log -S TODO
does.
Solution
If that TODO is in files (as opposed to the commit message), you can do:
git log -p --author=you -S TODO | grep "\+.*TODO"
See more at "How to grep (search) committed code in the git history?".
-p
: to see the content as a patch, which allows to grep on the line including the TODO.
However, this lists all TODO
comments ever written, even those that already resolved and thus removed again from code.
For a more complete answer, see "How to list all my TODO messages in the current git managed code base":
git grep -l TODO | xargs -n1 git blame -f -n -w | grep "Your name" | grep TODO | sed "s/.\{9\}//" | sed "s/(.*)[[:space:]]*//"