This will be necessary when we use a secondary working tree to do
reverts without leaving the primary working tree in an inconsistent
state.
(cherry picked from commit
39b8931ad31fe6b48afdc570caa459a0996c2092)
-my $git_dir=undef;
-my $prefix=undef;
+my @git_dir_stack;
+my $prefix;
+ unshift @git_dir_stack, shift;
$prefix=undef;
return @ret;
}
$prefix=undef;
return @ret;
}
if (!$pid) {
# In child.
# Git commands want to be in wc.
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 $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': $!");
}
}
exec @cmdline or error("Cannot exec '@cmdline': $!");
}
die $@ if $@;
my $fh;
($fh, $path)=File::Temp::tempfile(undef, UNLINK => 1);
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'.");
"git show $detail->{sha1_to} > '$path'";
if (system($cmd) != 0) {
error("failed writing temp file '$path'.");