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. */
5 /* Ok, it hasn't been so bad so far. */
9 #include "../exec_cmd.h"
11 /* XS and Perl interface */
19 MODULE = Git PACKAGE = Git
23 # /* TODO: xs_call_gate(). See Git.pm. */
40 RETVAL = git_exec_path();
47 xs__execv_git_cmd(...)
53 argv = malloc(sizeof(const char *) * (items + 1));
55 croak("malloc failed");
56 for (i = 0; i < items; i++)
57 argv[i] = strdup(SvPV_nolen(ST(i)));
62 for (i = 0; i < items; i++)
64 free((char *) argv[i]);
69 xs_hash_object(file, type = "blob")
74 unsigned char sha1[20];
76 if (SvTYPE(file) == SVt_RV)
79 if (SvTYPE(file) == SVt_PVGV) {
83 pio = IoIFP(sv_2io(file));
85 croak("You passed me something weird - a dir glob?");
86 /* XXX: I just hope PerlIO didn't read anything from it yet.
88 if (index_pipe(sha1, PerlIO_fileno(pio), type, 0))
89 croak("Unable to hash given filehandle");
90 /* Avoid any nasty surprises. */
95 char *path = SvPV_nolen(file);
96 int fd = open(path, O_RDONLY);
100 fstat(fd, &st) < 0 ||
101 index_fd(sha1, fd, &st, 0, type))
102 croak("Unable to hash %s", path);
105 RETVAL = sha1_to_hex(sha1);