Skip to content

Commit c14c8ce

Browse files
neoeinsteingitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4370c2d commit c14c8ce

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

perl/Git.pm

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@ use Carp qw(carp croak); # but croak is bad - throw instead
100100
use Error qw(:try);
101101
use Cwd qw(abs_path);
102102
use IPC::Open2 qw(open2);
103-
use File::Temp ();
104-
require File::Spec;
105103
use Fcntl qw(SEEK_SET SEEK_CUR);
106104
}
107105

@@ -1009,6 +1007,8 @@ sub temp_release {
10091007
sub _temp_cache {
10101008
my ($name) = @_;
10111009

1010+
_verify_require();
1011+
10121012
my $temp_fd = \$TEMP_FILES{$name};
10131013
if (defined $$temp_fd and $$temp_fd->opened) {
10141014
if ($TEMP_LOCKS{$$temp_fd}) {
@@ -1031,6 +1031,11 @@ sub _temp_cache {
10311031
$$temp_fd;
10321032
}
10331033

1034+
sub _verify_require {
1035+
eval { require File::Temp; require File::Spec; };
1036+
$@ and throw Error::Simple($@);
1037+
}
1038+
10341039
=item temp_reset ( FILEHANDLE )
10351040
10361041
Truncates and resets the position of the C<FILEHANDLE>.

0 commit comments

Comments
 (0)