git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Git.pm: Make _temp_cache use the repository directory
@ 2008-11-12 14:28 Marten Svanfeldt (dev)
  2008-11-12 22:06 ` [msysGit] " Clifford Caoile
  0 siblings, 1 reply; 3+ messages in thread
From: Marten Svanfeldt (dev) @ 2008-11-12 14:28 UTC (permalink / raw)
  To: msysgit, git; +Cc: Eric Wong

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [msysGit] [PATCH] Git.pm: Make _temp_cache use the repository directory
  2008-11-12 14:28 [PATCH] Git.pm: Make _temp_cache use the repository directory Marten Svanfeldt (dev)
@ 2008-11-12 22:06 ` Clifford Caoile
  2008-11-12 23:27   ` Marten Svanfeldt (dev)
  0 siblings, 1 reply; 3+ messages in thread
From: Clifford Caoile @ 2008-11-12 22:06 UTC (permalink / raw)
  To: developer; +Cc: msysgit, git, Eric Wong

Hi Marten Svanfeldt:

On Wed, Nov 12, 2008 at 11:28 PM, Marten Svanfeldt (dev)
<developer@svanfeldt.com> wrote:
>
> Update the usage of File::Temp->tempfile to place the temporary files
> within the repository directory instead of just letting Perl decide what
> [snip]
> +
> +               my $tmpdir;
> +               if (defined $self) {
> +                       $tmpdir = $self->repo_path();
> +               }
> +

I suppose if I wanted to used ${workingdir}/.git instead of
${workingdir}, I should replace the $tmpdir line above with $tmpdir =
$self->repo_path() . "/.git" ?

Best regards,
Clifford Caoile

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Git.pm: Make _temp_cache use the repository directory
  2008-11-12 22:06 ` [msysGit] " Clifford Caoile
@ 2008-11-12 23:27   ` Marten Svanfeldt (dev)
  0 siblings, 0 replies; 3+ messages in thread
From: Marten Svanfeldt (dev) @ 2008-11-12 23:27 UTC (permalink / raw)
  To: piyo; +Cc: msysgit, git, Eric Wong


Hi,

Clifford Caoile wrote:
> Hi Marten Svanfeldt:
> 
> On Wed, Nov 12, 2008 at 11:28 PM, Marten Svanfeldt (dev)
> <developer@svanfeldt.com> wrote:
..
> I suppose if I wanted to used ${workingdir}/.git instead of
> ${workingdir}, I should replace the $tmpdir line above with $tmpdir =
> $self->repo_path() . "/.git" ?

No. repo_path() is the path to the repository, so the .git directory. If
you instead want within the working directory it is wc_path().

> 
> Best regards,
> Clifford Caoile

-Marten Svanfeldt

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-11-12 23:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-12 14:28 [PATCH] Git.pm: Make _temp_cache use the repository directory Marten Svanfeldt (dev)
2008-11-12 22:06 ` [msysGit] " Clifford Caoile
2008-11-12 23:27   ` Marten Svanfeldt (dev)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).