X-Git-Url: https://scripts.mit.edu/gitweb/www/ikiwiki.git/blobdiff_plain/33f42db2ea0422551223c255d85d9f4e45ee404b..b14f84c4acccbc8450a9102b3b647013989b27bb:/IkiWiki/Plugin/git.pm diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm index e10283f59..86d80186f 100644 --- a/IkiWiki/Plugin/git.pm +++ b/IkiWiki/Plugin/git.pm @@ -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_getmtime", call => \&rcs_getmtime); hook(type => "rcs", id => "rcs_receive", call => \&rcs_receive); } @@ -51,6 +52,9 @@ sub checkconfig () { wrappermode => (defined $config{git_wrappermode} ? $config{git_wrappermode} : "06755"), }; } + + # Avoid notes, parser does not handle and they only slow things down. + $ENV{GIT_NOTES_REF}=""; # Run receive test only if being called by the wrapper, and not # when generating same. @@ -65,6 +69,7 @@ sub getsetup () { plugin => { safe => 0, # rcs plugin rebuild => undef, + section => "rcs", }, git_wrapper => { type => "string", @@ -419,7 +424,10 @@ sub git_sha1 (;$) { '--', $file); if ($sha1) { ($sha1) = $sha1 =~ m/($sha1_pattern)/; # sha1 is untainted now - } else { debug("Empty sha1sum for '$file'.") } + } + else { + debug("Empty sha1sum for '$file'."); + } return defined $sha1 ? $sha1 : q{}; } @@ -613,16 +621,24 @@ sub rcs_getctime ($) { # Remove srcdir prefix $file =~ s/^\Q$config{srcdir}\E\/?//; - my @raw_lines = run_or_die('git', 'log', '--reverse', '--follow', + my @raw_lines = run_or_die('git', 'log', + '--follow', '--no-merges', '--pretty=raw', '--raw', '--abbrev=40', '--always', '-c', '-r', '--', $file); - my $first = parse_diff_tree("", \@raw_lines); - my $ctime = $first->{'author_epoch'}; + my @ci; + while (my $parsed = parse_diff_tree("", \@raw_lines)) { + push @ci, $parsed; + } + my $ctime = $ci[$#ci]->{'author_epoch'}; debug("ctime for '$file': ". localtime($ctime)); return $ctime; } +sub rcs_getmtime ($) { + error "rcs_getmtime is not implemented for git\n"; # TODO +} + sub rcs_receive () { # The wiki may not be the only thing in the git repo. # Determine if it is in a subdirectory by examining the srcdir,