Use Ryan's git-annotate instead of jsannotate
Since Ryan's git-annotate is much faster, and has support for renames, it is likely it goes into the mainstream git soon. Adapt it a little to work with gitcvs, and actually use it. Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
Johannes Schindelin committed
Feb 20, 2006 at 16:20 UTC
4788d11a0d2ff872d25840768b2266e936a0b1fc
1 file changed
+40
-5
git-annotate.perl
+40
-5
@@ -8,9 +8,25 @@
8
9
use warnings;
10
use strict;
11
+use Getopt::Std;
12
+use POSIX qw(strftime gmtime);
13
12
-my $filename = shift @ARGV;
14
+sub usage() {
15
+ print STDERR 'Usage: ${\basename $0} [-s] [-S revs-file] file
16
+
17
+ -l show long rev
18
+ -r follow renames
19
+ -S commit use revs from revs-file instead of calling git-rev-list
20
+';
21
+
22
+ exit(1);
23
+}
24
25
+our ($opt_h, $opt_l, $opt_r, $opt_S);
26
+getopts("hlrS:") or usage();
27
+$opt_h && usage();
28
+
29
+my $filename = shift @ARGV;
30
31
my @stack = (
32
{
@@ -41,12 +57,19 @@ while (my $bound = pop @stack) {
57
my ($rev, @parents) = @$revinst;
58
$head ||= $rev;
59
60
+ if (!defined($rev)) {
61
+ $rev = "";
62
+ }
63
$revs{$rev}{'filename'} = $bound->{'filename'};
64
if (scalar @parents > 0) {
65
$revs{$rev}{'parents'} = \@parents;
66
next;
67
}
68
69
+ if (!$opt_r) {
70
+ next;
71
+ }
72
+
73
my $newbound = find_parent_renames($rev, $bound->{'filename'});
74
if ( exists $newbound->{'filename'} && $newbound->{'filename'} ne $bound->{'filename'}) {
75
push @stack, $newbound;
@@ -65,7 +88,7 @@ foreach my $l (@filelines) {
88
my ($output, $rev, $committer, $date);
89
if (ref $l eq 'ARRAY') {
90
($output, $rev, $committer, $date) = @$l;
68
- if (length($rev) > 8) {
91
+ if (!$opt_l && length($rev) > 8) {
92
$rev = substr($rev,0,8);
93
}
94
} else {
@@ -73,7 +96,8 @@ foreach my $l (@filelines) {
96
($rev, $committer, $date) = ('unknown', 'unknown', 'unknown');
97
}
98
76
- printf("(%8s %10s %10s %d)%s\n", $rev, $committer, $date, $i++, $output);
99
+ printf("%s\t(%10s\t%10s\t%d)%s\n", $rev, $committer,
100
+ format_date($date), $i++, $output);
101
}
102
103
sub init_claim {
@@ -119,8 +143,12 @@ sub handle_rev {
143
sub git_rev_list {
144
my ($rev, $file) = @_;
145
122
- open(P,"-|","git-rev-list","--parents","--remove-empty",$rev,"--",$file)
123
- or die "Failed to exec git-rev-list: $!";
146
+ if ($opt_S) {
147
+ open(P, '<' . $opt_S);
148
+ } else {
149
+ open(P,"-|","git-rev-list","--parents","--remove-empty",$rev,"--",$file)
150
+ or die "Failed to exec git-rev-list: $!";
151
+ }
152
153
my @revs;
154
while(my $line = <P>) {
@@ -319,3 +347,10 @@ sub git_commit_info {
347
348
return %info;
349
}
350
+
351
+sub format_date {
352
+ my ($timestamp, $timezone) = split(' ', $_[0]);
353
+
354
+ return strftime("%Y-%m-%d %H:%M:%S " . $timezone, gmtime($timestamp));
355
+}
356
+