aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki
diff options
context:
space:
mode:
Diffstat (limited to 'IkiWiki')
-rw-r--r--IkiWiki/Plugin/cvs.pm13
-rw-r--r--IkiWiki/Wrapper.pm3
2 files changed, 14 insertions, 2 deletions
diff --git a/IkiWiki/Plugin/cvs.pm b/IkiWiki/Plugin/cvs.pm
index 759ea1c23..bccab3159 100644
--- a/IkiWiki/Plugin/cvs.pm
+++ b/IkiWiki/Plugin/cvs.pm
@@ -502,7 +502,16 @@ sub cvs_runcvs(@) {
my @cmd = @_;
unshift @cmd, 'cvs', '-Q';
- local $CWD = $config{srcdir};
+ # CVS can't operate outside a srcdir, so we're always setting $CWD.
+ # "local $CWD" restores the previous value when we go out of scope.
+ # Usually that's correct. But if we're removing the last file from
+ # a directory, the post-commit hook will exec in a working directory
+ # that's about to not exist (CVS will prune it).
+ #
+ # chdir() manually here, so we can selectively not chdir() back.
+
+ my $oldcwd = $CWD;
+ chdir($config{srcdir});
eval q{
use IPC::Open3;
@@ -530,6 +539,8 @@ sub cvs_runcvs(@) {
print STDOUT $cvsout;
print STDERR $cvserr;
+ chdir($oldcwd) if -d $oldcwd;
+
return ($ret == 0) ? 1 : 0;
}
diff --git a/IkiWiki/Wrapper.pm b/IkiWiki/Wrapper.pm
index 06be36dfc..84b4b5a2f 100644
--- a/IkiWiki/Wrapper.pm
+++ b/IkiWiki/Wrapper.pm
@@ -28,10 +28,11 @@ sub gen_wrappers () {
%config=(%origconfig);
}
+our $program_to_wrap = $0;
sub gen_wrapper () {
$config{srcdir}=File::Spec->rel2abs($config{srcdir});
$config{destdir}=File::Spec->rel2abs($config{destdir});
- my $this=File::Spec->rel2abs($0);
+ my $this=File::Spec->rel2abs($program_to_wrap);
if (! -x $this) {
error(sprintf(gettext("%s doesn't seem to be executable"), $this));
}