aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2016-12-28 18:02:59 +0000
committerSimon McVittie <smcv@debian.org>2016-12-28 21:32:12 +0000
commit39b8931ad31fe6b48afdc570caa459a0996c2092 (patch)
tree183045d8621f6b54392cdff9ae42983589fc1905 /IkiWiki
parentad04dac19b1fbba33cbb7dadb17ae0ef0423b2e1 (diff)
downloadikiwiki-39b8931ad31fe6b48afdc570caa459a0996c2092.tar
ikiwiki-39b8931ad31fe6b48afdc570caa459a0996c2092.tar.gz
git: Turn $git_dir into a stack
This will be necessary when we use a secondary working tree to do reverts without leaving the primary working tree in an inconsistent state.
Diffstat (limited to 'IkiWiki')
-rw-r--r--IkiWiki/Plugin/git.pm16
1 files changed, 8 insertions, 8 deletions
diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm
index 56d649372..346808f04 100644
--- a/IkiWiki/Plugin/git.pm
+++ b/IkiWiki/Plugin/git.pm
@@ -153,13 +153,13 @@ sub genwrapper {
}
}
-my $git_dir=undef;
-my $prefix=undef;
+my @git_dir_stack;
+my $prefix;
sub in_git_dir ($$) {
- $git_dir=shift;
+ unshift @git_dir_stack, shift;
my @ret=shift->();
- $git_dir=undef;
+ shift @git_dir_stack;
$prefix=undef;
return @ret;
}
@@ -178,13 +178,13 @@ sub safe_git (&@) {
if (!$pid) {
# In child.
# Git commands want to be in wc.
- if (! defined $git_dir) {
+ if (! @git_dir_stack) {
chdir $config{srcdir}
or error("cannot chdir to $config{srcdir}: $!");
}
else {
- chdir $git_dir
- or error("cannot chdir to $git_dir: $!");
+ chdir $git_dir_stack[0]
+ or error("cannot chdir to $git_dir_stack[0]: $!");
}
exec @cmdline or error("Cannot exec '@cmdline': $!");
}
@@ -919,7 +919,7 @@ sub git_parse_changes {
die $@ if $@;
my $fh;
($fh, $path)=File::Temp::tempfile(undef, UNLINK => 1);
- my $cmd = "cd $git_dir && ".
+ my $cmd = "cd $git_dir_stack[0] && ".
"git show $detail->{sha1_to} > '$path'";
if (system($cmd) != 0) {
error("failed writing temp file '$path'.");