Git.pm: Call external commands using execv_git_cmd()
Instead of explicitly using the git wrapper to call external commands, use the execv_git_cmd() function which will directly call whatever needs to be called. GitBin option becomes useless so drop it. This actually means the exec_path() thing I planned to use worthless internally, but Jakub wants it in anyway and I don't mind, so... Signed-off-by: Petr Baudis <pasky@suse.cz> Signed-off-by: Junio C Hamano <junkio@cox.net>
Petr Baudis committed
Jun 24, 2006 at 04:34 UTC
8062f81c2d9df5e6552bf267b258ffcc5f647f93
2 files changed
+28
-6
perl/Git.pm
+6
-6
@@ -122,9 +122,6 @@ to the subdirectory and the directory is assumed to be the working copy.
122
If the directory does not have the subdirectory, C<WorkingCopy> is left
123
undefined and C<Repository> is pointed to the directory itself.
124
125
-B<GitPath> - Path to the C<git> binary executable. By default the C<$PATH>
126
-is searched for it.
127
-
125
You should not use both C<Directory> and either of C<Repository> and
126
C<WorkingCopy> - the results of that are undefined.
127
@@ -363,11 +360,14 @@ sub _cmd_exec {
360
$self->{opts}->{Repository} and $ENV{'GIT_DIR'} = $self->{opts}->{Repository};
361
$self->{opts}->{WorkingCopy} and chdir($self->{opts}->{WorkingCopy});
362
}
366
- my $git = $self->{opts}->{GitPath};
367
- $git ||= 'git';
368
- exec ($git, @args) or croak "exec failed: $!";
363
+ xs__execv_git_cmd(@args);
364
+ croak "exec failed: $!";
365
}
366
367
+# Execute the given Git command ($_[0]) with arguments ($_[1..])
368
+# by searching for it at proper places.
369
+# _execv_git_cmd(), implemented in Git.xs.
370
+
371
# Close pipe to a subprocess.
372
sub _cmd_close {
373
my ($fh) = @_;
perl/Git.xs
+22
@@ -33,6 +33,28 @@ OUTPUT:
33
RETVAL
34
35
36
+void
37
+xs__execv_git_cmd(...)
38
+CODE:
39
+{
40
+ const char **argv;
41
+ int i;
42
+
43
+ argv = malloc(sizeof(const char *) * (items + 1));
44
+ if (!argv)
45
+ croak("malloc failed");
46
+ for (i = 0; i < items; i++)
47
+ argv[i] = strdup(SvPV_nolen(ST(i)));
48
+ argv[i] = NULL;
49
+
50
+ execv_git_cmd(argv);
51
+
52
+ for (i = 0; i < items; i++)
53
+ if (argv[i])
54
+ free((char *) argv[i]);
55
+ free((char **) argv);
56
+}
57
+
58
char *
59
xs_hash_object(file, type = "blob")
60
SV *file;