]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/git.pm
setting cookies before aggregating
[git.ikiwiki.info.git] / IkiWiki / Plugin / git.pm
index 33ec00d8ad140b1c06024a5432698ce6c3fe00c1..e8981325357132c109b9160c11a2f0884f1ab8a8 100644 (file)
@@ -27,9 +27,7 @@ sub import {
        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_preprevert", call => \&rcs_preprevert);
-       hook(type => "rcs", id => "rcs_revert", call => \&rcs_revert);
-       hook(type => "rcs", id => "rcs_showpatch", call => \&rcs_showpatch);
+       hook(type => "rcs", id => "rcs_preprevert", call => \&rcs_preprevert);
        hook(type => "rcs", id => "rcs_revert", call => \&rcs_revert);
 }
 
@@ -742,7 +740,7 @@ sub git_find_root {
                }
        }
 
-       return $subdir;
+       return $git_root=$subdir;
 }
 
 }
@@ -796,8 +794,6 @@ sub git_parse_changes {
                                die $@ if $@;
                                my $fh;
                                ($fh, $path)=File::Temp::tempfile("XXXXXXXXXX", UNLINK => 1);
-                               # Ensure we run this in the right place,
-                               # see comments in rcs_receive.
                                my $cmd = ($no_chdir ? '' : "cd $config{srcdir} && ")
                                        . "git show $detail->{sha1_to} > '$path'";
                                if (system($cmd) != 0) {
@@ -838,40 +834,25 @@ sub rcs_receive () {
        return reverse @rets;
 }
 
-sub rcs_preprevert (@) {
-       my %params = @_;
-       my $rev = $params{rev};
+sub rcs_preprevert ($) {
+       my $rev=shift;
+       my ($sha1) = $rev =~ /^($sha1_pattern)$/; # untaint
 
-       # Note test_changes expects 'cgi' and 'session' parameters.
-       require IkiWiki::Receive;
-       IkiWiki::Receive::test_changes(%params, changes =>
-               [git_parse_changes(git_commit_info($rev, 1))]);
+       return git_parse_changes(git_commit_info($sha1, 1));
 }
 
-sub rcs_revert (@) {
-       # Try to revert the given patch; returns undef on _success_.
-       my %params = @_;
-       my $rev = $params{rev};
+sub rcs_revert ($) {
+       # Try to revert the given rev; returns undef on _success_.
+       my $rev = shift;
+       my ($sha1) = $rev =~ /^($sha1_pattern)$/; # untaint
 
-       if (run_or_non('git', 'revert', '--no-commit', $rev)) {
-               debug "Committing revert for patch '$rev'.";
-               rcs_commit_staged(message => 
-                       sprintf(gettext("This reverts commit %s"), $rev), @_);
+       if (run_or_non('git', 'revert', '--no-commit', $sha1)) {
+               return undef;
        }
        else {
-               # No idea what is actually getting reverted, so all we can
-               # do is say we failed.
                run_or_die('git', 'reset', '--hard');
-               return sprintf(gettext("Failed to revert commit %s"), $rev);
+               return sprintf(gettext("Failed to revert commit %s"), $sha1);
        }
 }
 
-sub rcs_showpatch (@) {
-    # Show the patch with the given revision id.
-    my %params = @_;
-    my $rev = $params{rev};
-
-    return join "\n", run_or_die('git', 'show', $rev);
-}
-
 1