summaryrefslogtreecommitdiff
path: root/perl
diff options
context:
space:
mode:
authorMarcus Griep <marcus@griep.us>2008-08-15 19:53:59 (GMT)
committerJunio C Hamano <gitster@pobox.com>2008-08-16 09:58:22 (GMT)
commitc14c8ceb13b299892f286757e22e6af4f6cffab5 (patch)
treef8641bec9df58af987c67cd0ad3a864aefbb9c57 /perl
parent4370c2d620df93343e52432d92e3a3c031916697 (diff)
downloadgit-c14c8ceb13b299892f286757e22e6af4f6cffab5.zip
git-c14c8ceb13b299892f286757e22e6af4f6cffab5.tar.gz
git-c14c8ceb13b299892f286757e22e6af4f6cffab5.tar.bz2
Git.pm: Make File::Spec and File::Temp requirement lazy
This will ensure that the API at large is accessible to nearly all Perl versions, while only the temp file caching API is tied to the File::Temp and File::Spec modules being available. Signed-off-by: Marcus Griep <marcus@griep.us> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'perl')
-rw-r--r--perl/Git.pm9
1 files changed, 7 insertions, 2 deletions
diff --git a/perl/Git.pm b/perl/Git.pm
index 405f68f..102e6a4 100644
--- a/perl/Git.pm
+++ b/perl/Git.pm
@@ -100,8 +100,6 @@ use Carp qw(carp croak); # but croak is bad - throw instead
use Error qw(:try);
use Cwd qw(abs_path);
use IPC::Open2 qw(open2);
-use File::Temp ();
-require File::Spec;
use Fcntl qw(SEEK_SET SEEK_CUR);
}
@@ -1009,6 +1007,8 @@ sub temp_release {
sub _temp_cache {
my ($name) = @_;
+ _verify_require();
+
my $temp_fd = \$TEMP_FILES{$name};
if (defined $$temp_fd and $$temp_fd->opened) {
if ($TEMP_LOCKS{$$temp_fd}) {
@@ -1031,6 +1031,11 @@ sub _temp_cache {
$$temp_fd;
}
+sub _verify_require {
+ eval { require File::Temp; require File::Spec; };
+ $@ and throw Error::Simple($@);
+}
+
=item temp_reset ( FILEHANDLE )
Truncates and resets the position of the C<FILEHANDLE>.