The string to match might not be "New directory" exactly, so match that
[ikiwiki.git] / IkiWiki / Wrapper.pm
index 8a6340f58c4f1ec5a6b77587672e0721f0f250c7..87c2ffc89f0e9543c6ed8d095a8a7ae73921ab05 100644 (file)
@@ -44,6 +44,17 @@ EOF
                $test_receive=IkiWiki::Receive::gen_wrapper();
        }
 
+       my $check_cvs_add_dir="";
+       # XXX conditionalize on $config{rcs} eq 'cvs'
+       $check_cvs_add_dir=<<"EOF";
+       {
+               int j;
+               for (j = 1; j < argc; j++)
+                       if (strstr(argv[j], "New directory") != NULL)
+                               exit(0);
+       }
+EOF
+
        my $check_commit_hook="";
        my $pre_exec="";
        if ($config{post_commit}) {
@@ -93,10 +104,7 @@ EOF
        $configstring=~s/"/\\"/g;
        $configstring=~s/\n/\\n/g;
        
-       #translators: The first parameter is a filename, and the second is
-       #translators: a (probably not translated) error message.
-       open(OUT, ">$wrapper.c") || error(sprintf(gettext("failed to write %s: %s"), "$wrapper.c", $!));;
-       print OUT <<"EOF";
+       writefile(basename("$wrapper.c"), dirname($wrapper), <<"EOF");
 /* A wrapper for ikiwiki, can be safely made suid. */
 #include <stdio.h>
 #include <sys/types.h>
@@ -122,6 +130,7 @@ addenv(char *var, char *val) {
 int main (int argc, char **argv) {
        char *s;
 
+$check_cvs_add_dir
 $check_commit_hook
 $test_receive
 $envsave