Skip to content

Commit bcdd1b4

Browse files
theboltEric Wong
authored andcommitted
Git.pm: Make _temp_cache use the repository directory
Update the usage of File::Temp->tempfile to place the temporary files within the repository directory instead of just letting Perl decide what directory to use, given there is a repository specified when requesting the temporary file. This is needed to be able to fix git-svn on msys as msysperl generates paths with UNIX-style paths (/tmp/xxx) while the git tools expect natvie path format (c:/..). The repository dir is stored in native format so by using it as the base directory for temporary files we always get a usable native full path. Signed-off-by: Marten Svanfeldt <[email protected]> Acked-by: Eric Wong <[email protected]>
1 parent fe4003f commit bcdd1b4

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

perl/Git.pm

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -961,9 +961,7 @@ issue.
961961
=cut
962962

963963
sub temp_acquire {
964-
my ($self, $name) = _maybe_self(@_);
965-
966-
my $temp_fd = _temp_cache($name);
964+
my $temp_fd = _temp_cache(@_);
967965

968966
$TEMP_FILES{$temp_fd}{locked} = 1;
969967
$temp_fd;
@@ -1005,7 +1003,7 @@ sub temp_release {
10051003
}
10061004

10071005
sub _temp_cache {
1008-
my ($name) = @_;
1006+
my ($self, $name) = _maybe_self(@_);
10091007

10101008
_verify_require();
10111009

@@ -1022,9 +1020,16 @@ sub _temp_cache {
10221020
"' was closed. Opening replacement.";
10231021
}
10241022
my $fname;
1023+
1024+
my $tmpdir;
1025+
if (defined $self) {
1026+
$tmpdir = $self->repo_path();
1027+
}
1028+
10251029
($$temp_fd, $fname) = File::Temp->tempfile(
1026-
'Git_XXXXXX', UNLINK => 1
1030+
'Git_XXXXXX', UNLINK => 1, DIR => $tmpdir,
10271031
) or throw Error::Simple("couldn't open new temp file");
1032+
10281033
$$temp_fd->autoflush;
10291034
binmode $$temp_fd;
10301035
$TEMP_FILES{$$temp_fd}{fname} = $fname;

0 commit comments

Comments
 (0)