]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/git.pm
turn on tag_autocreate by default if tagbase is set
[git.ikiwiki.info.git] / IkiWiki / Plugin / git.pm
index 1eec6aee61eaf2c28e0e2187236dcec02db95ca9..aa402c04f4e461b9450a0192313de1dda8726f49 100644 (file)
@@ -25,6 +25,7 @@ sub import {
        hook(type => "rcs", id => "rcs_recentchanges", call => \&rcs_recentchanges);
        hook(type => "rcs", id => "rcs_diff", call => \&rcs_diff);
        hook(type => "rcs", id => "rcs_getctime", call => \&rcs_getctime);
        hook(type => "rcs", id => "rcs_recentchanges", call => \&rcs_recentchanges);
        hook(type => "rcs", id => "rcs_diff", call => \&rcs_diff);
        hook(type => "rcs", id => "rcs_getctime", call => \&rcs_getctime);
+       hook(type => "rcs", id => "rcs_getmtime", call => \&rcs_getmtime);
        hook(type => "rcs", id => "rcs_receive", call => \&rcs_receive);
 }
 
        hook(type => "rcs", id => "rcs_receive", call => \&rcs_receive);
 }
 
@@ -68,6 +69,7 @@ sub getsetup () {
                plugin => {
                        safe => 0, # rcs plugin
                        rebuild => undef,
                plugin => {
                        safe => 0, # rcs plugin
                        rebuild => undef,
+                       section => "rcs",
                },
                git_wrapper => {
                        type => "string",
                },
                git_wrapper => {
                        type => "string",
@@ -614,23 +616,51 @@ sub rcs_diff ($) {
        }
 }
 
        }
 }
 
-sub rcs_getctime ($) {
+{
+my %time_cache;
+
+sub findtimes ($$) {
        my $file=shift;
        my $file=shift;
+       my $id=shift; # 0 = mtime ; 1 = ctime
+
        # Remove srcdir prefix
        $file =~ s/^\Q$config{srcdir}\E\/?//;
 
        # Remove srcdir prefix
        $file =~ s/^\Q$config{srcdir}\E\/?//;
 
-       my @raw_lines = run_or_die('git', 'log', 
-               '--follow', '--no-merges',
-               '--pretty=raw', '--raw', '--abbrev=40', '--always', '-c',
-               '-r', '--', $file);
-       my @ci;
-       while (my $parsed = parse_diff_tree("", \@raw_lines)) {
-               push @ci, $parsed;
+       if (! keys %time_cache) {
+               my $date;
+               foreach my $line (run_or_die('git', 'log',
+                               '--pretty=format:%ct',
+                               '--name-only', '--relative')) {
+                       if (! defined $date && $line =~ /^(\d+)$/) {
+                               $date=$line;
+                       }
+                       elsif (! length $line) {
+                               $date=undef;
+                       }
+                       else {
+                               if (! $time_cache{$line}) {
+                                       $time_cache{$line}[0]=$date; # mtime
+                               }
+                               $time_cache{$line}[1]=$date; # ctime
+                       }
+               }
        }
        }
-       my $ctime = $ci[$#ci]->{'author_epoch'};
-       debug("ctime for '$file': ". localtime($ctime));
 
 
-       return $ctime;
+       return exists $time_cache{$file} ? $time_cache{$file}[$id] : 0;
+}
+
+}
+
+sub rcs_getctime ($) {
+       my $file=shift;
+
+       return findtimes($file, 1);
+}
+
+sub rcs_getmtime ($) {
+       my $file=shift;
+
+       return findtimes($file, 0);
 }
 
 sub rcs_receive () {
 }
 
 sub rcs_receive () {