]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Wrapper.pm
web commit by joey
[ikiwiki.git] / IkiWiki / Wrapper.pm
index 238f71a91bdc28360e6a0910b1d391c8d45e25d0..d723684463dda687e21be6d18341ce0c6ac0d1d5 100644 (file)
@@ -28,7 +28,6 @@ sub gen_wrapper () { #{{{
        push @envsave, qw{REMOTE_ADDR QUERY_STRING REQUEST_METHOD REQUEST_URI
                       CONTENT_TYPE CONTENT_LENGTH GATEWAY_INTERFACE
                       HTTP_COOKIE} if $config{cgi};
-       push @envsave, qw{REV} if $config{svn};
        my $envsave="";
        foreach my $var (@envsave) {
                $envsave.=<<"EOF"
@@ -36,6 +35,16 @@ sub gen_wrapper () { #{{{
                asprintf(&newenviron[i++], "%s=%s", "$var", s);
 EOF
        }
+       if ($config{svn} && $config{notify}) {
+               # Support running directly as hooks/post-commit by passing
+               # $2 in REV in the environment.
+               $envsave.=<<"EOF"
+       if (argc == 3)
+               asprintf(&newenviron[i++], "REV=%s", argv[2]);
+       else if ((s=getenv("REV")))
+               asprintf(&newenviron[i++], "%s=%s", "REV", s);
+EOF
+       }
        
        $Data::Dumper::Indent=0; # no newlines
        my $configstring=Data::Dumper->Dump([\%config], ['*config']);
@@ -56,7 +65,7 @@ extern char **environ;
 int main (int argc, char **argv) {
        /* Sanitize environment. */
        char *s;
-       char *newenviron[$#envsave+4];
+       char *newenviron[$#envsave+5];
        int i=0;
 $envsave
        newenviron[i++]="HOME=$ENV{HOME}";