diff options
author | Amitai Schlair <schmonz-web-ikiwiki@schmonz.com> | 2013-01-27 22:09:57 -0500 |
---|---|---|
committer | Amitai Schlair <schmonz-web-ikiwiki@schmonz.com> | 2013-01-27 22:09:57 -0500 |
commit | b30cacdf8da07f40af03f1b26021d8ec4d8b8b4c (patch) | |
tree | 204e454c2d5b5fe6e09300fe0f259c6c55392ae7 /IkiWiki/Plugin | |
parent | 4d4c15a7c6f3ee073bf6d8aaf9a9a8b0b4c7fb40 (diff) | |
download | ikiwiki-b30cacdf8da07f40af03f1b26021d8ec4d8b8b4c.tar ikiwiki-b30cacdf8da07f40af03f1b26021d8ec4d8b8b4c.tar.gz |
Fix longstanding bug (chdir to nonexistent dirs).
In test, set up the post-commit hook for more realism (and bugs!).
To make wrappers work in test, set PERL5LIB, and allow the wrappee's
path to be overridden. Meta-test that post-commit is really hooked
up by verifying that content is getting generated in destdir.
About the longstanding bug, which as far as I know was harmless:
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).
The fix: chdir() manually in cvs_runcvs(), so we can selectively
not chdir() back.
Diffstat (limited to 'IkiWiki/Plugin')
-rw-r--r-- | IkiWiki/Plugin/cvs.pm | 13 |
1 files changed, 12 insertions, 1 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; } |