@@ -93,9 +93,6 @@ use Carp qw(carp croak); # but croak is bad - throw instead
93
93
use Error qw( :try) ;
94
94
use Cwd qw( abs_path) ;
95
95
96
- require XSLoader;
97
- XSLoader::load(' Git' , $VERSION );
98
-
99
96
}
100
97
101
98
@@ -413,25 +410,23 @@ sub command_noisy {
413
410
414
411
Return the Git version in use.
415
412
416
- Implementation of this function is very fast; no external command calls
417
- are involved.
418
-
419
413
=cut
420
414
421
- # Implemented in Git.xs.
415
+ sub version {
416
+ my $verstr = command_oneline(' --version' );
417
+ $verstr =~ s / ^git version // ;
418
+ $verstr ;
419
+ }
422
420
423
421
424
422
=item exec_path ()
425
423
426
424
Return path to the Git sub-command executables (the same as
427
425
C<git --exec-path > ). Useful mostly only internally.
428
426
429
- Implementation of this function is very fast; no external command calls
430
- are involved.
431
-
432
427
=cut
433
428
434
- # Implemented in Git.xs.
429
+ sub exec_path { command_oneline( ' --exec-path ' ) }
435
430
436
431
437
432
=item repo_path ()
@@ -572,41 +567,21 @@ sub ident_person {
572
567
573
568
=item hash_object ( TYPE, FILENAME )
574
569
575
- =item hash_object ( TYPE, FILEHANDLE )
576
-
577
570
Compute the SHA1 object id of the given C<FILENAME > (or data waiting in
578
571
C<FILEHANDLE > ) considering it is of the C<TYPE > object type (C<blob > ,
579
572
C<commit > , C<tree > ).
580
573
581
- In case of C<FILEHANDLE > passed instead of file name, all the data
582
- available are read and hashed, and the filehandle is automatically
583
- closed. The file handle should be freshly opened - if you have already
584
- read anything from the file handle, the results are undefined (since
585
- this function works directly with the file descriptor and internal
586
- PerlIO buffering might have messed things up).
587
-
588
574
The method can be called without any instance or on a specified Git repository,
589
575
it makes zero difference.
590
576
591
577
The function returns the SHA1 hash.
592
578
593
- Implementation of this function is very fast; no external command calls
594
- are involved.
595
-
596
579
=cut
597
580
581
+ # TODO: Support for passing FILEHANDLE instead of FILENAME
598
582
sub hash_object {
599
583
my ($self , $type , $file ) = _maybe_self(@_ );
600
-
601
- # hash_object_* implemented in Git.xs.
602
-
603
- if (ref ($file ) eq ' GLOB' ) {
604
- my $hash = hash_object_pipe($type , fileno ($file ));
605
- close $file ;
606
- return $hash ;
607
- } else {
608
- hash_object_file($type , $file );
609
- }
584
+ command_oneline(' hash-object' , ' -t' , $type , $file );
610
585
}
611
586
612
587
@@ -802,7 +777,7 @@ sub _cmd_exec {
802
777
803
778
# Execute the given Git command ($_[0]) with arguments ($_[1..])
804
779
# by searching for it at proper places.
805
- # _execv_git_cmd(), implemented in Git.xs.
780
+ sub _execv_git_cmd { exec ( ' git ' , @_ ); }
806
781
807
782
# Close pipe to a subprocess.
808
783
sub _cmd_close {
@@ -821,39 +796,6 @@ sub _cmd_close {
821
796
}
822
797
823
798
824
- # Trickery for .xs routines: In order to avoid having some horrid
825
- # C code trying to do stuff with undefs and hashes, we gate all
826
- # xs calls through the following and in case we are being ran upon
827
- # an instance call a C part of the gate which will set up the
828
- # environment properly.
829
- sub _call_gate {
830
- my $xsfunc = shift ;
831
- my ($self , @args ) = _maybe_self(@_ );
832
-
833
- if (defined $self ) {
834
- # XXX: We ignore the WorkingCopy! To properly support
835
- # that will require heavy changes in libgit.
836
-
837
- # XXX: And we ignore everything else as well. libgit
838
- # at least needs to be extended to let us specify
839
- # the $GIT_DIR instead of looking it up in environment.
840
- # xs_call_gate($self->{opts}->{Repository});
841
- }
842
-
843
- # Having to call throw from the C code is a sure path to insanity.
844
- local $SIG {__DIE__ } = sub { throw Error::Simple(" @_ " ); };
845
- &$xsfunc (@args );
846
- }
847
-
848
- sub AUTOLOAD {
849
- my $xsname ;
850
- our $AUTOLOAD ;
851
- ($xsname = $AUTOLOAD ) =~ s / .*::// ;
852
- throw Error::Simple(" &Git::$xsname not defined" ) if $xsname =~ / ^xs_/ ;
853
- $xsname = ' xs_' .$xsname ;
854
- _call_gate(\&$xsname , @_ );
855
- }
856
-
857
799
sub DESTROY { }
858
800
859
801
0 commit comments