@@ -11,9 +11,6 @@ use 5.008;
11
11
use strict;
12
12
use warnings $ENV {GIT_PERL_FATAL_WARNINGS } ? qw( FATAL all) : ();
13
13
14
- use File::Temp ();
15
- use File::Spec ();
16
-
17
14
BEGIN {
18
15
19
16
our ($VERSION , @ISA , @EXPORT , @EXPORT_OK );
@@ -103,12 +100,9 @@ increase notwithstanding).
103
100
=cut
104
101
105
102
106
- use Carp qw( carp croak) ; # but croak is bad - throw instead
103
+ sub carp { require Carp; goto &Carp::carp }
104
+ sub croak { require Carp; goto &Carp::croak }
107
105
use Git::LoadCPAN::Error qw( :try) ;
108
- use Cwd qw( abs_path cwd) ;
109
- use IPC::Open2 qw( open2) ;
110
- use Fcntl qw( SEEK_SET SEEK_CUR) ;
111
- use Time::Local qw( timegm) ;
112
106
}
113
107
114
108
@@ -191,13 +185,15 @@ sub repository {
191
185
$dir = undef ;
192
186
};
193
187
188
+ require Cwd;
194
189
if ($dir ) {
190
+ require File::Spec;
195
191
File::Spec-> file_name_is_absolute($dir ) or $dir = $opts {Directory } . ' /' . $dir ;
196
- $opts {Repository } = abs_path($dir );
192
+ $opts {Repository } = Cwd:: abs_path($dir );
197
193
198
194
# If --git-dir went ok, this shouldn't die either.
199
195
my $prefix = $search -> command_oneline(' rev-parse' , ' --show-prefix' );
200
- $dir = abs_path($opts {Directory }) . ' /' ;
196
+ $dir = Cwd:: abs_path($opts {Directory }) . ' /' ;
201
197
if ($prefix ) {
202
198
if (substr ($dir , -length ($prefix )) ne $prefix ) {
203
199
throw Error::Simple(" rev-parse confused me - $dir does not have trailing $prefix " );
@@ -223,7 +219,7 @@ sub repository {
223
219
throw Error::Simple(" fatal: Not a git repository: $dir " );
224
220
}
225
221
226
- $opts {Repository } = abs_path($dir );
222
+ $opts {Repository } = Cwd:: abs_path($dir );
227
223
}
228
224
229
225
delete $opts {Directory };
@@ -408,10 +404,12 @@ sub command_bidi_pipe {
408
404
my $cwd_save = undef ;
409
405
if ($self ) {
410
406
shift ;
411
- $cwd_save = cwd();
407
+ require Cwd;
408
+ $cwd_save = Cwd::cwd();
412
409
_setup_git_cmd_env($self );
413
410
}
414
- $pid = open2($in , $out , ' git' , @_ );
411
+ require IPC::Open2;
412
+ $pid = IPC::Open2::open2($in , $out , ' git' , @_ );
415
413
chdir ($cwd_save ) if $cwd_save ;
416
414
return ($pid , $in , $out , join (' ' , @_ ));
417
415
}
@@ -538,7 +536,8 @@ sub get_tz_offset {
538
536
my $t = shift || time ;
539
537
my @t = localtime ($t );
540
538
$t [5] += 1900;
541
- my $gm = timegm(@t );
539
+ require Time::Local;
540
+ my $gm = Time::Local::timegm(@t );
542
541
my $sign = qw( + + - ) [ $gm <=> $t ];
543
542
return sprintf (" %s %02d%02d" , $sign , (gmtime (abs($t - $gm )))[2,1]);
544
543
}
@@ -1340,6 +1339,7 @@ sub _temp_cache {
1340
1339
my $n = $name ;
1341
1340
$n =~ s /\W / _/ g ; # no strange chars
1342
1341
1342
+ require File::Temp;
1343
1343
($$temp_fd , $fname ) = File::Temp::tempfile(
1344
1344
" Git_${n} _XXXXXX" , UNLINK => 1, DIR => $tmpdir ,
1345
1345
) or throw Error::Simple(" couldn't open new temp file" );
@@ -1362,9 +1362,9 @@ sub temp_reset {
1362
1362
1363
1363
truncate $temp_fd , 0
1364
1364
or throw Error::Simple(" couldn't truncate file" );
1365
- sysseek($temp_fd , 0, SEEK_SET) and seek ($temp_fd , 0, SEEK_SET)
1365
+ sysseek($temp_fd , 0, Fcntl:: SEEK_SET()) and seek ($temp_fd , 0, Fcntl:: SEEK_SET() )
1366
1366
or throw Error::Simple(" couldn't seek to beginning of file" );
1367
- sysseek($temp_fd , 0, SEEK_CUR) == 0 and tell ($temp_fd ) == 0
1367
+ sysseek($temp_fd , 0, Fcntl:: SEEK_CUR() ) == 0 and tell ($temp_fd ) == 0
1368
1368
or throw Error::Simple(" expected file position to be reset" );
1369
1369
}
1370
1370
0 commit comments