Handle file renames inside directories.
[git-plot.git] / user.sh
blobeed5087e2052f7eaa2b9ae77b96f7c8909ca77a1
1 #!/bin/bash
3 if [ $# -lt 1 ]; then
4 echo "Usage: $0 <output image>.png [geometry]" >&2
5 exit 1;
6 fi
8 TMP=$1
9 output="$1.png"
10 echo "Outputting to image $output, tmp = $TMP"
12 x=600
13 y=400
15 if [ $# -gt 1 ]; then
16 x=$2;
17 y=$3;
20 git log -C --numstat --reverse --pretty=format:"%H %an" | perl -e '
21 use strict;
23 my %users;
25 my $line = 1;
27 sub add_commit {
28 my ($author, $ins, $del) = @_;
29 $users{$author} += ($ins - $del);
32 my $author = "";
33 my $ins = 0;
34 my $del = 0;
35 while( <> ) {
36 if( $_ =~ /^[0-9]+[\t ]+[0-9]+/ ) {
37 my ($add, $rem, $file) = split;
38 #if( not $file =~ /^devices\/[a-z]+/ ) {
39 $ins += $add;
40 $del += $rem;
42 next;
44 if( $_ =~ /^[0-9a-z]+/ ) {
45 my ($commit, $an) = split(/\s+/, $_, 2);
46 if( $line != 1 ) {
47 &add_commit($author, $ins, $del);
48 $ins = 0;
49 $del = 0;
52 chomp($an);
53 $author = $an;
56 $line++;
59 &add_commit($author, $ins, $del);
61 my ($author, $value);
62 foreach $author (keys %users) {
63 print "$author $users{$author}\n";
65 ' > $TMP
67 #lines=$(wc -l $TMP | cut -f1 -d' ')
69 gnuplot << _EOF_
70 set terminal png nocrop medium size $x,$y
71 set output '$output'
72 plot "$TMP" using 2 with boxes
73 _EOF_
75 rm $TMP