Lars Blumberg Lars Blumberg - 1 year ago 68
Git Question

How to list all my TODO messages in the current git managed code base

I want to see all TODO comments that only I wrote and that exist in the current code base that is git managed.

What I've got so far is printing all TODO comments that I've ever created or modified during the complete git history:

git log -p --author="My name" -S TODO | grep "\+.*TODO"

But this tool chain lists all TODO comments ever written, even those that I've already resolved and thus removed again from code.

Is there a tool that can search the current code base line-by-line, check if it contains "TODO" and if this line was authored by me and then print those lines?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download