]> asedeno.scripts.mit.edu Git - git.git/blobdiff - perl/Git.pm
Git.pm: Make _temp_cache use the repository directory
[git.git] / perl / Git.pm
index ba94453781c98a97a95c65999873fc28b013340d..dde9105df8464911451830321e4da1cbae924955 100644 (file)
@@ -961,9 +961,7 @@ issue.
 =cut
 
 sub temp_acquire {
-       my ($self, $name) = _maybe_self(@_);
-
-       my $temp_fd = _temp_cache($name);
+       my $temp_fd = _temp_cache(@_);
 
        $TEMP_FILES{$temp_fd}{locked} = 1;
        $temp_fd;
@@ -1005,7 +1003,7 @@ sub temp_release {
 }
 
 sub _temp_cache {
-       my ($name) = @_;
+       my ($self, $name) = _maybe_self(@_);
 
        _verify_require();
 
@@ -1022,9 +1020,16 @@ sub _temp_cache {
                                "' was closed. Opening replacement.";
                }
                my $fname;
+
+               my $tmpdir;
+               if (defined $self) {
+                       $tmpdir = $self->repo_path();
+               }
+
                ($$temp_fd, $fname) = File::Temp->tempfile(
-                       'Git_XXXXXX', UNLINK => 1
+                       'Git_XXXXXX', UNLINK => 1, DIR => $tmpdir,
                        ) or throw Error::Simple("couldn't open new temp file");
+
                $$temp_fd->autoflush;
                binmode $$temp_fd;
                $TEMP_FILES{$$temp_fd}{fname} = $fname;