Skip to content

Commit

Permalink
Git.pm: Kill Git.xs for now
Browse files Browse the repository at this point in the history
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 <pasky@suse.cz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Petr Baudis authored and Junio C Hamano committed Sep 23, 2006
1 parent 81a7173 commit 18b0fc1
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 224 deletions.
17 changes: 5 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ PIC_FLAG = -fPIC
LDFLAGS =
ALL_CFLAGS = $(CFLAGS)
ALL_LDFLAGS = $(LDFLAGS)
PERL_CFLAGS =
PERL_LDFLAGS =
STRIP ?= strip

prefix = $(HOME)
Expand Down Expand Up @@ -154,9 +152,10 @@ SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
### --- END CONFIGURATION SECTION ---

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

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


PERL_DEFINE = $(BASIC_CFLAGS) -DGIT_VERSION='"$(GIT_VERSION)"'
PERL_DEFINE_SQ = $(subst ','\'',$(PERL_DEFINE))
PERL_LIBS = $(BASIC_LDFLAGS) $(EXTLIBS)
PERL_LIBS_SQ = $(subst ','\'',$(PERL_LIBS))
perl/Makefile: perl/Git.pm perl/Makefile.PL GIT-CFLAGS
(cd perl && $(PERL_PATH) Makefile.PL \
PREFIX='$(prefix_SQ)' \
DEFINE='$(PERL_DEFINE_SQ)' \
LIBS='$(PERL_LIBS_SQ)')
PREFIX='$(prefix_SQ)')

doc:
$(MAKE) -C Documentation all
Expand Down
3 changes: 0 additions & 3 deletions perl/.gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
Git.bs
Git.c
Makefile
blib
blibdirs
pm_to_blib
ppport.h
76 changes: 9 additions & 67 deletions perl/Git.pm
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ use Carp qw(carp croak); # but croak is bad - throw instead
use Error qw(:try);
use Cwd qw(abs_path);

require XSLoader;
XSLoader::load('Git', $VERSION);

}


Expand Down Expand Up @@ -413,25 +410,23 @@ sub command_noisy {
Return the Git version in use.
Implementation of this function is very fast; no external command calls
are involved.
=cut

# Implemented in Git.xs.
sub version {
my $verstr = command_oneline('--version');
$verstr =~ s/^git version //;
$verstr;
}


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

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


=item repo_path ()
Expand Down Expand Up @@ -572,41 +567,21 @@ sub ident_person {

=item hash_object ( TYPE, FILENAME )
=item hash_object ( TYPE, FILEHANDLE )
Compute the SHA1 object id of the given C<FILENAME> (or data waiting in
C<FILEHANDLE>) considering it is of the C<TYPE> object type (C<blob>,
C<commit>, C<tree>).
In case of C<FILEHANDLE> passed instead of file name, all the data
available are read and hashed, and the filehandle is automatically
closed. The file handle should be freshly opened - if you have already
read anything from the file handle, the results are undefined (since
this function works directly with the file descriptor and internal
PerlIO buffering might have messed things up).
The method can be called without any instance or on a specified Git repository,
it makes zero difference.
The function returns the SHA1 hash.
Implementation of this function is very fast; no external command calls
are involved.
=cut

# TODO: Support for passing FILEHANDLE instead of FILENAME
sub hash_object {
my ($self, $type, $file) = _maybe_self(@_);

# hash_object_* implemented in Git.xs.

if (ref($file) eq 'GLOB') {
my $hash = hash_object_pipe($type, fileno($file));
close $file;
return $hash;
} else {
hash_object_file($type, $file);
}
command_oneline('hash-object', '-t', $type, $file);
}


Expand Down Expand Up @@ -802,7 +777,7 @@ sub _cmd_exec {

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

# Close pipe to a subprocess.
sub _cmd_close {
Expand All @@ -821,39 +796,6 @@ sub _cmd_close {
}


# Trickery for .xs routines: In order to avoid having some horrid
# C code trying to do stuff with undefs and hashes, we gate all
# xs calls through the following and in case we are being ran upon
# an instance call a C part of the gate which will set up the
# environment properly.
sub _call_gate {
my $xsfunc = shift;
my ($self, @args) = _maybe_self(@_);

if (defined $self) {
# XXX: We ignore the WorkingCopy! To properly support
# that will require heavy changes in libgit.

# XXX: And we ignore everything else as well. libgit
# at least needs to be extended to let us specify
# the $GIT_DIR instead of looking it up in environment.
#xs_call_gate($self->{opts}->{Repository});
}

# Having to call throw from the C code is a sure path to insanity.
local $SIG{__DIE__} = sub { throw Error::Simple("@_"); };
&$xsfunc(@args);
}

sub AUTOLOAD {
my $xsname;
our $AUTOLOAD;
($xsname = $AUTOLOAD) =~ s/.*:://;
throw Error::Simple("&Git::$xsname not defined") if $xsname =~ /^xs_/;
$xsname = 'xs_'.$xsname;
_call_gate(\&$xsname, @_);
}

sub DESTROY { }


Expand Down
134 changes: 0 additions & 134 deletions perl/Git.xs

This file was deleted.

9 changes: 1 addition & 8 deletions perl/Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ use ExtUtils::MakeMaker;
sub MY::postamble {
return <<'MAKE_FRAG';
instlibdir:
@echo '$(INSTALLSITEARCH)'
check:
perl -MDevel::PPPort -le 'Devel::PPPort::WriteFile(".ppport.h")' && \
perl .ppport.h --compat-version=5.6.0 Git.xs && \
rm .ppport.h
@echo '$(INSTALLSITELIB)'
MAKE_FRAG
}
Expand All @@ -29,7 +24,5 @@ WriteMakefile(
NAME => 'Git',
VERSION_FROM => 'Git.pm',
PM => \%pm,
MYEXTLIB => '../libgit.a',
INC => '-I. -I..',
%extra
);

0 comments on commit 18b0fc1

Please sign in to comment.