All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Marten Svanfeldt (dev)" <developer@svanfeldt.com>
To: msysgit@googlegroups.com, git@vger.kernel.org
Cc: Eric Wong <normalperson@yhbt.net>
Subject: [PATCH] Git.pm: Make _temp_cache use the repository directory
Date: Wed, 12 Nov 2008 22:28:26 +0800	[thread overview]
Message-ID: <491AE80A.5060807@svanfeldt.com> (raw)

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 fixes issues when the Perl in use uses a different format for paths
than in use by native code in the git tools such as msysgit with msys-perl.

Signed-off-by: Marten Svanfeldt <developer@svanfeldt.com>
---
 perl/Git.pm |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/perl/Git.pm b/perl/Git.pm
index 6aab712..4b71dad 100644
--- a/perl/Git.pm
+++ b/perl/Git.pm
@@ -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;
-- 
1.6.0.3.1437.g6c121.dirty

             reply	other threads:[~2008-11-12 14:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-12 14:28 Marten Svanfeldt (dev) [this message]
2008-11-12 22:06 ` [msysGit] [PATCH] Git.pm: Make _temp_cache use the repository directory Clifford Caoile
2008-11-12 23:27   ` Marten Svanfeldt (dev)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=491AE80A.5060807@svanfeldt.com \
    --to=developer@svanfeldt.com \
    --cc=git@vger.kernel.org \
    --cc=msysgit@googlegroups.com \
    --cc=normalperson@yhbt.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.