@matheusbsbs / matheus-bagliano / commits / 18b0fc1ce1
Fork 0

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 <pasky@suse.cz> Signed-off-by: Junio C Hamano <junkio@cox.net>

Petr Baudis committed Sep 23, 2006 at 20:20 UTC 18b0fc1ce1ef92716d4c5d5c7acd5d5a61a0a556
5 files changed +15 -224
Makefile
+5 -12
@@ -116,8 +116,6 @@ PIC_FLAG = -fPIC
116 LDFLAGS =
117 ALL_CFLAGS = $(CFLAGS)
118 ALL_LDFLAGS = $(LDFLAGS)
119 -PERL_CFLAGS =
120 -PERL_LDFLAGS =
119 STRIP ?= strip
120
121 prefix = $(HOME)
@@ -154,9 +152,10 @@ SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
152 ### --- END CONFIGURATION SECTION ---
153
154 # 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 =
159
160 SCRIPT_SH = \
161 git-bisect.sh git-branch.sh git-checkout.sh \
@@ -753,15 +752,9 @@ $(XDIFF_LIB): $(XDIFF_OBJS)
752 rm -f $@ && $(AR) rcs $@ $(XDIFF_OBJS)
753
754
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))
755 perl/Makefile: perl/Git.pm perl/Makefile.PL GIT-CFLAGS
756 (cd perl && $(PERL_PATH) Makefile.PL \
762 - PREFIX='$(prefix_SQ)' \
763 - DEFINE='$(PERL_DEFINE_SQ)' \
764 - LIBS='$(PERL_LIBS_SQ)')
757 + PREFIX='$(prefix_SQ)')
758
759 doc:
760 $(MAKE) -C Documentation all
perl/.gitignore
-3
@@ -1,7 +1,4 @@
1 -Git.bs
2 -Git.c
1 Makefile
2 blib
3 blibdirs
4 pm_to_blib
7 -ppport.h
perl/Git.pm
+9 -67
@@ -93,9 +93,6 @@ use Carp qw(carp croak); # but croak is bad - throw instead
93 use Error qw(:try);
94 use Cwd qw(abs_path);
95
96 -require XSLoader;
97 -XSLoader::load('Git', $VERSION);
98 -
96 }
97
98
@@ -413,12 +410,13 @@ sub command_noisy {
410
411 Return the Git version in use.
412
416 -Implementation of this function is very fast; no external command calls
417 -are involved.
418 -
413 =cut
414
421 -# Implemented in Git.xs.
415 +sub version {
416 + my $verstr = command_oneline('--version');
417 + $verstr =~ s/^git version //;
418 + $verstr;
419 +}
420
421
422 =item exec_path ()
@@ -426,12 +424,9 @@ are involved.
424 Return path to the Git sub-command executables (the same as
425 C<git --exec-path>). Useful mostly only internally.
426
429 -Implementation of this function is very fast; no external command calls
430 -are involved.
431 -
427 =cut
428
434 -# Implemented in Git.xs.
429 +sub exec_path { command_oneline('--exec-path') }
430
431
432 =item repo_path ()
@@ -572,41 +567,21 @@ sub ident_person {
567
568 =item hash_object ( TYPE, FILENAME )
569
575 -=item hash_object ( TYPE, FILEHANDLE )
576 -
570 Compute the SHA1 object id of the given C<FILENAME> (or data waiting in
571 C<FILEHANDLE>) considering it is of the C<TYPE> object type (C<blob>,
572 C<commit>, C<tree>).
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 -
574 The method can be called without any instance or on a specified Git repository,
575 it makes zero difference.
576
577 The function returns the SHA1 hash.
578
593 -Implementation of this function is very fast; no external command calls
594 -are involved.
595 -
579 =cut
580
581 +# TODO: Support for passing FILEHANDLE instead of FILENAME
582 sub hash_object {
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);
585 }
586
587
@@ -802,7 +777,7 @@ sub _cmd_exec {
777
778 # Execute the given Git command ($_[0]) with arguments ($_[1..])
779 # by searching for it at proper places.
805 -# _execv_git_cmd(), implemented in Git.xs.
780 +sub _execv_git_cmd { exec('git', @_); }
781
782 # Close pipe to a subprocess.
783 sub _cmd_close {
@@ -821,39 +796,6 @@ sub _cmd_close {
796 }
797
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 -
799 sub DESTROY { }
800
801
perl/Git.xs deleted
-134
@@ -1,134 +0,0 @@
1 -/* By carefully stacking #includes here (even if WE don't really need them)
2 - * we strive to make the thing actually compile. Git header files aren't very
3 - * nice. Perl headers are one of the signs of the coming apocalypse. */
4 -#include <ctype.h>
5 -/* Ok, it hasn't been so bad so far. */
6 -
7 -/* libgit interface */
8 -#include "../cache.h"
9 -#include "../exec_cmd.h"
10 -
11 -/* XS and Perl interface */
12 -#include "EXTERN.h"
13 -#include "perl.h"
14 -#include "XSUB.h"
15 -
16 -
17 -static char *
18 -report_xs(const char *prefix, const char *err, va_list params)
19 -{
20 - static char buf[4096];
21 - strcpy(buf, prefix);
22 - vsnprintf(buf + strlen(prefix), 4096 - strlen(prefix), err, params);
23 - return buf;
24 -}
25 -
26 -static void NORETURN
27 -die_xs(const char *err, va_list params)
28 -{
29 - char *str;
30 - str = report_xs("fatal: ", err, params);
31 - croak(str);
32 -}
33 -
34 -static void
35 -error_xs(const char *err, va_list params)
36 -{
37 - char *str;
38 - str = report_xs("error: ", err, params);
39 - warn(str);
40 -}
41 -
42 -
43 -MODULE = Git PACKAGE = Git
44 -
45 -PROTOTYPES: DISABLE
46 -
47 -
48 -BOOT:
49 -{
50 - set_error_routine(error_xs);
51 - set_die_routine(die_xs);
52 -}
53 -
54 -
55 -# /* TODO: xs_call_gate(). See Git.pm. */
56 -
57 -
58 -char *
59 -xs_version()
60 -CODE:
61 -{
62 - RETVAL = GIT_VERSION;
63 -}
64 -OUTPUT:
65 - RETVAL
66 -
67 -
68 -char *
69 -xs_exec_path()
70 -CODE:
71 -{
72 - RETVAL = (char *)git_exec_path();
73 -}
74 -OUTPUT:
75 - RETVAL
76 -
77 -
78 -void
79 -xs__execv_git_cmd(...)
80 -CODE:
81 -{
82 - const char **argv;
83 - int i;
84 -
85 - argv = malloc(sizeof(const char *) * (items + 1));
86 - if (!argv)
87 - croak("malloc failed");
88 - for (i = 0; i < items; i++)
89 - argv[i] = strdup(SvPV_nolen(ST(i)));
90 - argv[i] = NULL;
91 -
92 - execv_git_cmd(argv);
93 -
94 - for (i = 0; i < items; i++)
95 - if (argv[i])
96 - free((char *) argv[i]);
97 - free((char **) argv);
98 -}
99 -
100 -char *
101 -xs_hash_object_pipe(type, fd)
102 - char *type;
103 - int fd;
104 -CODE:
105 -{
106 - unsigned char sha1[20];
107 -
108 - if (index_pipe(sha1, fd, type, 0))
109 - croak("Unable to hash given filehandle");
110 - RETVAL = sha1_to_hex(sha1);
111 -}
112 -OUTPUT:
113 - RETVAL
114 -
115 -char *
116 -xs_hash_object_file(type, path)
117 - char *type;
118 - char *path;
119 -CODE:
120 -{
121 - unsigned char sha1[20];
122 - int fd = open(path, O_RDONLY);
123 - struct stat st;
124 -
125 - if (fd < 0 ||
126 - fstat(fd, &st) < 0 ||
127 - index_fd(sha1, fd, &st, 0, type))
128 - croak("Unable to hash %s", path);
129 - close(fd);
130 -
131 - RETVAL = sha1_to_hex(sha1);
132 -}
133 -OUTPUT:
134 - RETVAL
perl/Makefile.PL
+1 -8
@@ -3,12 +3,7 @@ use ExtUtils::MakeMaker;
3 sub MY::postamble {
4 return <<'MAKE_FRAG';
5 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)'
7
8 MAKE_FRAG
9 }
@@ -29,7 +24,5 @@ WriteMakefile(
24 NAME => 'Git',
25 VERSION_FROM => 'Git.pm',
26 PM => \%pm,
32 - MYEXTLIB => '../libgit.a',
33 - INC => '-I. -I..',
27 %extra
28 );