0

I already know how to get the difference between 2 commits, also get them file by file. I also know (thanks to this thread Count number of lines in a git repository ) That you can use Cloc to only get the actual lines of code instead of all lines.

But How would I do to get the difference in lines of code only in git, I:E using cloc on 2 different commits?

This gives me a printout of code with what is added (+) before and what is deleted (-). But here I can't use cloc directly, I would have todo some parsing

git diff `git rev-list --since="jun 30 2014" --reverse origin/master | head -1`..`git rev-list --until="dec 31 2014" origin/master | head -1`

Here I get all files modified and added/changed lines first column. Problem is that this includes blank lines and comments.

git diff `git rev-list --since="jun 30 2014" --reverse origin/master | head -1`..`git rev-list --until="dec 31 2014" origin/master | head -1` --numstat

Is there any way to do the above without getting the blank lines or comments? I:E using Cloc instead of Gits own compare algorithm? And if so how can I do that?

Thanks in advance.

Community
  • 1
  • 1
anders
  • 1,535
  • 5
  • 19
  • 43

1 Answers1

1

If I understand you correctly the easiest way to achive what you want would be to follow these steps:

git checkout <commit-1>
cloc ./ > ../commit-1-cloc.txt

git checkokut <commit-2>
cloc ./ > ../commit-2-cloc.txt

You will then have two very nice tables showing you a lot of information like seen here

AnimiVulpis
  • 2,670
  • 1
  • 19
  • 27