I would separate this problem into subproblems:
Raw log magic
I would start by specifying a starting point from where the problem is relatively easy
If you run
git log
then you see a list of commit summaries. Of course, this is not friendly - yet.
Now, let's limit our domain, let's say we are interested in a statistic for the last 100 commits:
git log -100
Now the number of commits in question is appropriate. But we still don't see adds and removals, let's remedy that:
git log -100 --stat
Starts to be better, right? Let's improve it further:
git log -5 --stat --format=""
Much, much better. Now, for each commit you have "useful lines", that is, lines containing the number of changes and a last line of the format of
9 files changed, 189 insertions(+), 1 deletion(-)
basically, if you have a line containing "files changed" or "file changed", you need to ignore it, unless you have a file with that name. All the other lines are useful raw inputs.
Algorithm for statistics
You need a data structure that will contain the file type as key and a pair of numbers as value. The first number is the number of minuses, the second number is the number of pluses. Pseudocode:
For Each ln In Lines Do
If (Not ln.Replace("files", "file").Contains("file changed")) And ln.Contains(".") Then
FileExtension = ln.Substring(ln.IndexOf(".") + 1, ln.IndexOf(" "))
If (Not Extensions.Has(FileExtension)) Then
Extensions(FileExtension) = [0, 0]
End
UsefulSubstring = ln.Substring(ln.LastIndexOf(" ") + 1)
For Each char In UsefulSubstring Do
If char = '+' Then
Extensions(FileExtension)[1] = Extensions(FileExtension)[1] + 1
Else
Extensions(FileExtension)[0] = Extensions(FileExtension)[0] + 1
End If
End For
End If
End For
This algorithm will construct your output, which you need to put into the console output in the format you prefer. So, you can call this program with the input you prefer. You can even embed the git log command into the project. It's not a very big task, so if you invest a few hours into this, maybe less, you will have the result you need.