Following command outputs following lines of text on console
git log --pretty=format:\"%h;%ai;%s\" --shortstat
ed6e0ab;2014-01-07 16:32:39 +0530;Foo
3 files
git doesn't support stat info with plain --format, which is shame :( but it's easy to script it away, here's my quick and dirty solution, should be quite readable:
#!/bin/bash
format_log_entry ()
{
read commit
read date
read summary
local statnum=0
local add=0
local rem=0
while true; do
read statline
if [ -z "$statline" ]; then break; fi
((statnum += 1))
((add += $(echo $statline | cut -d' ' -f1)))
((rem += $(echo $statline | cut -d' ' -f2)))
done
if [ -n "$commit" ]; then
echo "$commit;$date;$summary;$statnum;$add;$rem"
else
exit 0
fi
}
while true; do
format_log_entry
done
I'm sure, that it can be scripted better, but hey - it's both quick AND dirty ;)
usage:
$ git log --pretty=format:"%h%n%ai%n%s" --numstat | ./script
Please note, that format, that you specified is not bulletproof. Semicolon can appear in commit summary, which will break number of fields in such line - you can either move summary to end of line or escape it somehow - how do you want to do it?