- if ($config{rcs} eq "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);
+
+ my $test_receive="";
+ if ($config{test_receive}) {
+ require IkiWiki::Receive;
+ $test_receive=IkiWiki::Receive::gen_wrapper();
+ }
+
+ my $check_commit_hook="";
+ my $pre_exec="";
+ if ($config{post_commit}) {
+ # Optimise checking !commit_hook_enabled() ,
+ # so that ikiwiki does not have to be started if the
+ # hook is disabled.
+ #
+ # Note that perl's flock may be implemented using fcntl
+ # or lockf on some systems. If so, and if there is no
+ # interop between the locking systems, the true C flock will
+ # always succeed, and this optimisation won't work.
+ # The perl code will later correctly check the lock,
+ # so the right thing will still happen, though without
+ # the benefit of this optimisation.
+ $check_commit_hook=<<"EOF";
+ {
+ int fd=open("$config{wikistatedir}/commitlock", O_CREAT | O_RDWR, 0666);
+ if (fd != -1) {
+ if (flock(fd, LOCK_SH | LOCK_NB) != 0)
+ exit(0);
+ close(fd);
+ }
+ }