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 */
18 report_xs(const char *prefix, const char *err, va_list params)
20 static char buf[4096];
22 vsnprintf(buf + strlen(prefix), 4096 - strlen(prefix), err, params);
27 die_xs(const char *err, va_list params)
30 str = report_xs("fatal: ", err, params);
35 error_xs(const char *err, va_list params)
38 str = report_xs("error: ", err, params);
43 MODULE = Git PACKAGE = Git
50 set_error_routine(error_xs);
51 set_die_routine(die_xs);
55 # /* TODO: xs_call_gate(). See Git.pm. */
72 RETVAL = (char *)git_exec_path();
79 xs__execv_git_cmd(...)
85 argv = malloc(sizeof(const char *) * (items + 1));
87 croak("malloc failed");
88 for (i = 0; i < items; i++)
89 argv[i] = strdup(SvPV_nolen(ST(i)));
94 for (i = 0; i < items; i++)
96 free((char *) argv[i]);
101 xs_hash_object_pipe(type, fd)
106 unsigned char sha1[20];
108 if (index_pipe(sha1, fd, type, 0))
109 croak("Unable to hash given filehandle");
110 RETVAL = sha1_to_hex(sha1);
116 xs_hash_object_file(type, path)
121 unsigned char sha1[20];
122 int fd = open(path, O_RDONLY);
126 fstat(fd, &st) < 0 ||
127 index_fd(sha1, fd, &st, 0, type))
128 croak("Unable to hash %s", path);
131 RETVAL = sha1_to_hex(sha1);