From: Abhijit Menon-Sen <ams@toroid.org>
To: Marcus Griep <neoeinstein@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>,
"Tom G. Christensen" <tgc@statsbiblioteket.dk>,
git@vger.kernel.org, Matthieu Moy <Matthieu.Moy@imag.fr>,
Petr Baudis <pasky@suse.cz>
Subject: Re: [PATCH] Git.pm: Use File::Temp->tempfile instead of ->new
Date: Mon, 8 Sep 2008 13:35:48 +0530 [thread overview]
Message-ID: <20080908080548.GA3206@toroid.org> (raw)
In-Reply-To: <48C40670.6090106@gmail.com>
At 2008-09-07 12:50:56 -0400, neoeinstein@gmail.com wrote:
>
> As I was the one who brought File::Temp->new over from git-svn, I can
> take a look at reducing the dependency to ->tempfile. If you don't
> patch in first, I'll get one in as well.
Please do.
Here's my latest patch, in case you find it useful as a starting point.
I do not have more time or inclination to work on this at the moment.
The problem with this patch is that the caller (git-svn in this case)
assumes that a File::Temp object will be returned, and depends on the
OO interface (e.g. by calling $tmp_fh->filename).
Unfortunately, I do not think the problem is limited to filename(). I
blessed $$temp_fd into a stub package that provided a fake filename()
method, but t9100-git-svn-basic.sh failed a little further on, and I
did not investigate further. Anyway, I don't think emulating the
File::Temp OO interface is a good solution at all.
(Tom: I'm sorry I ran out of energy before I could put together a
complete fix for you.)
-- ams
From: Abhijit Menon-Sen <ams@toroid.org>
Date: Mon, 8 Sep 2008 12:26:59 +0530
Subject: [PATCH] Git.pm: Use File::Temp->tempfile instead of ->new
Perl 5.8.0 ships with File::Temp 0.13, which does not have the new()
interface introduced in 0.14, as pointed out by Tom G. Christensen.
Signed-off-by: Abhijit Menon-Sen <ams@toroid.org>
---
perl/Git.pm | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/perl/Git.pm b/perl/Git.pm
index 102e6a4..b0498ca 100644
--- a/perl/Git.pm
+++ b/perl/Git.pm
@@ -991,7 +991,7 @@ the same string.
sub temp_release {
my ($self, $temp_fd, $trunc) = _maybe_self(@_);
- if (ref($temp_fd) ne 'File::Temp') {
+ if (exists $TEMP_FILES{$temp_fd}) {
$temp_fd = $TEMP_FILES{$temp_fd};
}
unless ($TEMP_LOCKS{$temp_fd}) {
@@ -1021,10 +1021,13 @@ sub _temp_cache {
carp "Temp file '", $name,
"' was closed. Opening replacement.";
}
- $$temp_fd = File::Temp->new(
- TEMPLATE => 'Git_XXXXXX',
- DIR => File::Spec->tmpdir
- ) or throw Error::Simple("couldn't open new temp file");
+ eval {
+ ($$temp_fd) = File::Temp->tempfile(
+ 'Git_XXXXXX',
+ DIR => File::Spec->tmpdir
+ );
+ };
+ throw Error::Simple("couldn't open new temp file") if $@;
$$temp_fd->autoflush;
binmode $$temp_fd;
}
--
1.6.0.1.196.g01914
next prev parent reply other threads:[~2008-09-08 8:07 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-01 9:27 Git 1.6.0.1 breaks git-svn with perl 5.8.0 Tom G. Christensen
2008-09-01 9:46 ` Matthieu Moy
2008-09-01 10:04 ` [PATCH] Git.pm: Require File::Temp 0.14 for new() Abhijit Menon-Sen
2008-09-01 10:21 ` Tom G. Christensen
2008-09-01 10:42 ` [PATCH] Git.pm: Use File::Temp->tempfile instead of ->new Abhijit Menon-Sen
2008-09-01 11:03 ` Tom G. Christensen
2008-09-07 5:27 ` Junio C Hamano
2008-09-07 9:26 ` Abhijit Menon-Sen
2008-09-07 16:50 ` Marcus Griep
2008-09-08 8:05 ` Abhijit Menon-Sen [this message]
2008-09-08 15:51 ` Marcus Griep
2008-09-08 16:53 ` [PATCH v2] " Marcus Griep
2008-09-09 1:53 ` Eric Wong
2008-09-10 3:53 ` Junio C Hamano
2008-09-10 10:09 ` Eric Wong
2008-09-09 2:06 ` Abhijit Menon-Sen
2008-09-09 17:35 ` Marcus Griep
2008-09-09 7:41 ` Tom G. Christensen
2008-09-09 17:55 ` Marcus Griep
2008-09-10 7:16 ` Tom G. Christensen
2008-09-10 15:09 ` [PATCH] git-svn: Fixes my() parameter list syntax error in pre-5.8 Perl Marcus Griep
2008-09-10 15:11 ` Marcus Griep
2008-09-01 10:13 ` Git 1.6.0.1 breaks git-svn with perl 5.8.0 Tom G. Christensen
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=20080908080548.GA3206@toroid.org \
--to=ams@toroid.org \
--cc=Matthieu.Moy@imag.fr \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=neoeinstein@gmail.com \
--cc=pasky@suse.cz \
--cc=tgc@statsbiblioteket.dk \
/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 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).