Skip to content

Commit 18b0fc1

Browse files
Petr BaudisJunio C Hamano
Petr Baudis
authored and
Junio C Hamano
committed
Git.pm: Kill Git.xs for now
This patch removes Git.xs from the repository for the time being. This should hopefully enable Git.pm to finally make its way to master. Git.xs is not going away forever. When the Git libification makes some progress, it will hopefully return (but most likely as an optional component, due to the portability woes) since the performance boosts are really important for applications like Gitweb or Cogito. It needs to go away now since it is not really reliable in case you use it for several repositories in the scope of a single process, and that is not possible to fix without some either very ugly or very intrusive core changes. Rest in peace. (While you can.) Signed-off-by: Petr Baudis <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 81a7173 commit 18b0fc1

File tree

5 files changed

+15
-224
lines changed

5 files changed

+15
-224
lines changed

Makefile

+5-12
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,6 @@ PIC_FLAG = -fPIC
116116
LDFLAGS =
117117
ALL_CFLAGS = $(CFLAGS)
118118
ALL_LDFLAGS = $(LDFLAGS)
119-
PERL_CFLAGS =
120-
PERL_LDFLAGS =
121119
STRIP ?= strip
122120

123121
prefix = $(HOME)
@@ -154,9 +152,10 @@ SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
154152
### --- END CONFIGURATION SECTION ---
155153

156154
# Those must not be GNU-specific; they are shared with perl/ which may
157-
# be built by a different compiler.
158-
BASIC_CFLAGS = $(PERL_CFLAGS)
159-
BASIC_LDFLAGS = $(PERL_LDFLAGS)
155+
# be built by a different compiler. (Note that this is an artifact now
156+
# but it still might be nice to keep that distinction.)
157+
BASIC_CFLAGS =
158+
BASIC_LDFLAGS =
160159

161160
SCRIPT_SH = \
162161
git-bisect.sh git-branch.sh git-checkout.sh \
@@ -753,15 +752,9 @@ $(XDIFF_LIB): $(XDIFF_OBJS)
753752
rm -f $@ && $(AR) rcs $@ $(XDIFF_OBJS)
754753

755754

756-
PERL_DEFINE = $(BASIC_CFLAGS) -DGIT_VERSION='"$(GIT_VERSION)"'
757-
PERL_DEFINE_SQ = $(subst ','\'',$(PERL_DEFINE))
758-
PERL_LIBS = $(BASIC_LDFLAGS) $(EXTLIBS)
759-
PERL_LIBS_SQ = $(subst ','\'',$(PERL_LIBS))
760755
perl/Makefile: perl/Git.pm perl/Makefile.PL GIT-CFLAGS
761756
(cd perl && $(PERL_PATH) Makefile.PL \
762-
PREFIX='$(prefix_SQ)' \
763-
DEFINE='$(PERL_DEFINE_SQ)' \
764-
LIBS='$(PERL_LIBS_SQ)')
757+
PREFIX='$(prefix_SQ)')
765758

766759
doc:
767760
$(MAKE) -C Documentation all

perl/.gitignore

-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
Git.bs
2-
Git.c
31
Makefile
42
blib
53
blibdirs
64
pm_to_blib
7-
ppport.h

perl/Git.pm

+9-67
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,6 @@ use Carp qw(carp croak); # but croak is bad - throw instead
9393
use Error qw(:try);
9494
use Cwd qw(abs_path);
9595

96-
require XSLoader;
97-
XSLoader::load('Git', $VERSION);
98-
9996
}
10097

10198

@@ -413,25 +410,23 @@ sub command_noisy {
413410
414411
Return the Git version in use.
415412
416-
Implementation of this function is very fast; no external command calls
417-
are involved.
418-
419413
=cut
420414

421-
# Implemented in Git.xs.
415+
sub version {
416+
my $verstr = command_oneline('--version');
417+
$verstr =~ s/^git version //;
418+
$verstr;
419+
}
422420

423421

424422
=item exec_path ()
425423
426424
Return path to the Git sub-command executables (the same as
427425
C<git --exec-path>). Useful mostly only internally.
428426
429-
Implementation of this function is very fast; no external command calls
430-
are involved.
431-
432427
=cut
433428

434-
# Implemented in Git.xs.
429+
sub exec_path { command_oneline('--exec-path') }
435430

436431

437432
=item repo_path ()
@@ -572,41 +567,21 @@ sub ident_person {
572567

573568
=item hash_object ( TYPE, FILENAME )
574569
575-
=item hash_object ( TYPE, FILEHANDLE )
576-
577570
Compute the SHA1 object id of the given C<FILENAME> (or data waiting in
578571
C<FILEHANDLE>) considering it is of the C<TYPE> object type (C<blob>,
579572
C<commit>, C<tree>).
580573
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-
588574
The method can be called without any instance or on a specified Git repository,
589575
it makes zero difference.
590576
591577
The function returns the SHA1 hash.
592578
593-
Implementation of this function is very fast; no external command calls
594-
are involved.
595-
596579
=cut
597580

581+
# TODO: Support for passing FILEHANDLE instead of FILENAME
598582
sub hash_object {
599583
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);
610585
}
611586

612587

@@ -802,7 +777,7 @@ sub _cmd_exec {
802777

803778
# Execute the given Git command ($_[0]) with arguments ($_[1..])
804779
# by searching for it at proper places.
805-
# _execv_git_cmd(), implemented in Git.xs.
780+
sub _execv_git_cmd { exec('git', @_); }
806781

807782
# Close pipe to a subprocess.
808783
sub _cmd_close {
@@ -821,39 +796,6 @@ sub _cmd_close {
821796
}
822797

823798

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-
857799
sub DESTROY { }
858800

859801

perl/Git.xs

-134
This file was deleted.

perl/Makefile.PL

+1-8
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@ use ExtUtils::MakeMaker;
33
sub MY::postamble {
44
return <<'MAKE_FRAG';
55
instlibdir:
6-
@echo '$(INSTALLSITEARCH)'
7-
8-
check:
9-
perl -MDevel::PPPort -le 'Devel::PPPort::WriteFile(".ppport.h")' && \
10-
perl .ppport.h --compat-version=5.6.0 Git.xs && \
11-
rm .ppport.h
6+
@echo '$(INSTALLSITELIB)'
127
138
MAKE_FRAG
149
}
@@ -29,7 +24,5 @@ WriteMakefile(
2924
NAME => 'Git',
3025
VERSION_FROM => 'Git.pm',
3126
PM => \%pm,
32-
MYEXTLIB => '../libgit.a',
33-
INC => '-I. -I..',
3427
%extra
3528
);

0 commit comments

Comments
 (0)