So I'm in a team with a few other programmers and need to get a lines-of-code count per author in our git repository. That doesn't just mean lines modified by author, because that would include blank and comment lines. Ideally, I would be able to make a new branch containing only the commits of a specific author (--author="BtheDestroyer" for myself) and then use cloc to get the comment line count and code line counts separately. I've tried using
git log --author="BtheDestroyer" --format=%H > mycommits
git checkout --orphan mycommits
tac mycommits| while read sha; do git cherry-pick --no-commit ${sha}; done
during the last line, however, I get a ton of the following errors:
filepath: unmerged (commit-id-1)
filepath: unmerged (commit-id-2)
error: your index file is unmerged.
fatal: cherry-pick failed
I'm also not sure if that will end up fastforwarding through other commits in the process. Any ideas?
Answering my own question:
I ended up using
git blameand a Bourne shell script to loop through different files in the source folder, convert them back to code usinggrepandcut, organize the output into temporary files, and then runclocon that.Here's my shell script for anyone wanting to do something similar (I have it in
./Blame/so changeSOURCEappropriately!):