summaryrefslogtreecommitdiff
path: root/perl
diff options
context:
space:
mode:
Diffstat (limited to 'perl')
-rw-r--r--perl/Git.pm12
-rw-r--r--perl/Git.xs22
2 files changed, 28 insertions, 6 deletions
diff --git a/perl/Git.pm b/perl/Git.pm
index 5c5ae12..212337e 100644
--- a/perl/Git.pm
+++ b/perl/Git.pm
@@ -122,9 +122,6 @@ to the subdirectory and the directory is assumed to be the working copy.
If the directory does not have the subdirectory, C<WorkingCopy> is left
undefined and C<Repository> is pointed to the directory itself.
-B<GitPath> - Path to the C<git> binary executable. By default the C<$PATH>
-is searched for it.
-
You should not use both C<Directory> and either of C<Repository> and
C<WorkingCopy> - the results of that are undefined.
@@ -363,11 +360,14 @@ sub _cmd_exec {
$self->{opts}->{Repository} and $ENV{'GIT_DIR'} = $self->{opts}->{Repository};
$self->{opts}->{WorkingCopy} and chdir($self->{opts}->{WorkingCopy});
}
- my $git = $self->{opts}->{GitPath};
- $git ||= 'git';
- exec ($git, @args) or croak "exec failed: $!";
+ xs__execv_git_cmd(@args);
+ croak "exec failed: $!";
}
+# Execute the given Git command ($_[0]) with arguments ($_[1..])
+# by searching for it at proper places.
+# _execv_git_cmd(), implemented in Git.xs.
+
# Close pipe to a subprocess.
sub _cmd_close {
my ($fh) = @_;
diff --git a/perl/Git.xs b/perl/Git.xs
index 9e754d2..6478f9c 100644
--- a/perl/Git.xs
+++ b/perl/Git.xs
@@ -33,6 +33,28 @@ OUTPUT:
RETVAL
+void
+xs__execv_git_cmd(...)
+CODE:
+{
+ const char **argv;
+ int i;
+
+ argv = malloc(sizeof(const char *) * (items + 1));
+ if (!argv)
+ croak("malloc failed");
+ for (i = 0; i < items; i++)
+ argv[i] = strdup(SvPV_nolen(ST(i)));
+ argv[i] = NULL;
+
+ execv_git_cmd(argv);
+
+ for (i = 0; i < items; i++)
+ if (argv[i])
+ free((char *) argv[i]);
+ free((char **) argv);
+}
+
char *
xs_hash_object(file, type = "blob")
SV *file;