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 <developer@svanfeldt.com> Acked-by: Eric Wong <normalperson@yhbt.net>
Marten Svanfeldt (dev) committed
Nov 13, 2008 at 20:04 UTC
bcdd1b4456998256df19ea0347bf4a7fa5410eef
1 file changed
+10
-5
perl/Git.pm
+10
-5
@@ -961,9 +961,7 @@ issue.
961
=cut
962
963
sub temp_acquire {
964
- my ($self, $name) = _maybe_self(@_);
965
-
966
- my $temp_fd = _temp_cache($name);
964
+ my $temp_fd = _temp_cache(@_);
965
966
$TEMP_FILES{$temp_fd}{locked} = 1;
967
$temp_fd;
@@ -1005,7 +1003,7 @@ sub temp_release {
1003
}
1004
1005
sub _temp_cache {
1008
- my ($name) = @_;
1006
+ my ($self, $name) = _maybe_self(@_);
1007
1008
_verify_require();
1009
@@ -1022,9 +1020,16 @@ sub _temp_cache {
1020
"' was closed. Opening replacement.";
1021
}
1022
my $fname;
1023
+
1024
+ my $tmpdir;
1025
+ if (defined $self) {
1026
+ $tmpdir = $self->repo_path();
1027
+ }
1028
+
1029
($$temp_fd, $fname) = File::Temp->tempfile(
1026
- 'Git_XXXXXX', UNLINK => 1
1030
+ 'Git_XXXXXX', UNLINK => 1, DIR => $tmpdir,
1031
) or throw Error::Simple("couldn't open new temp file");
1032
+
1033
$$temp_fd->autoflush;
1034
binmode $$temp_fd;
1035
$TEMP_FILES{$$temp_fd}{fname} = $fname;