{"thread":{"id":"4629","subject":"[PATCH] Git.pm: Call external commands using execv_git_cmd()","startedAt":"2006-06-22T23:37:52Z","lastAt":"2006-06-23T00:08:07Z","messageCount":2,"participants":["Petr Baudis","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"22319","messageId":"20060622233752.29122.78856.stgit@machine.or.cz","threadId":"4629","inReplyTo":null,"subject":"[PATCH] Git.pm: Call external commands using execv_git_cmd()","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2006-06-22T23:37:52Z","receivedAt":"2006-06-22T23:37:52Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Instead of explicitly using the git wrapper to call external commands,\nuse the execv_git_cmd() function which will directly call whatever\nneeds to be called. GitBin option becomes useless so drop it.\n\nThis actually means the exec_path() thing I planned to use worthless\ninternally, but Jakub wants it in anyway and I don't mind, so...\n\nSigned-off-by: Petr Baudis <pasky@suse.cz>\n---\n\n perl/Git.pm |   12 ++++++------\n perl/Git.xs |   20 ++++++++++++++++++++\n 2 files changed, 26 insertions(+), 6 deletions(-)\n\ndiff --git a/perl/Git.pm b/perl/Git.pm\nindex 516c065..5b233ed 100644\n--- a/perl/Git.pm\n+++ b/perl/Git.pm\n@@ -122,9 +122,6 @@ to the subdirectory and the directory is\n If the directory does not have the subdirectory, C<WorkingCopy> is left\n undefined and C<Repository> is pointed to the directory itself.\n \n-B<GitPath> - Path to the C<git> binary executable. By default the C<$PATH>\n-is searched for it.\n-\n You should not use both C<Directory> and either of C<Repository> and\n C<WorkingCopy> - the results of that are undefined.\n \n@@ -363,11 +360,14 @@ sub _cmd_exec {\n \t\t$self->{opts}->{Repository} and $ENV{'GIT_DIR'} = $self->{opts}->{Repository};\n \t\t$self->{opts}->{WorkingCopy} and chdir($self->{opts}->{WorkingCopy});\n \t}\n-\tmy $git = $self->{opts}->{GitPath};\n-\t$git ||= 'git';\n-\texec ($git, @args) or croak \"exec failed: $!\";\n+\txs__execv_git_cmd(@args);\n+\tcroak \"exec failed: $!\";\n }\n \n+# Execute the given Git command ($_[0]) with arguments ($_[1..])\n+# by searching for it at proper places.\n+# _execv_git_cmd(), implemented in Git.xs.\n+\n # Close pipe to a subprocess.\n sub _cmd_close {\n \tmy ($fh) = @_;\ndiff --git a/perl/Git.xs b/perl/Git.xs\nindex d1f94a4..f94ee95 100644\n--- a/perl/Git.xs\n+++ b/perl/Git.xs\n@@ -29,6 +29,26 @@ OUTPUT:\n \tRETVAL\n \n \n+void\n+xs__execv_git_cmd(...)\n+CODE:\n+\tconst char **argv;\n+\tint i;\n+\n+\targv = malloc(sizeof(const char *) * (items + 1));\n+\tif (!argv)\n+\t\tcroak(\"malloc failed\");\n+\tfor (i = 0; i < items; i++)\n+\t\targv[i] = strdup(SvPV_nolen(ST(i)));\n+\targv[i] = NULL;\n+\n+\texecv_git_cmd(argv);\n+\n+\tfor (i = 0; i < items; i++)\n+\t\tif (argv[i])\n+\t\t\tfree(argv[i]);\n+\tfree(argv);\n+\n char *\n xs_hash_object(file, type = \"blob\")\n \tSV *file;\n"},{"id":"22322","messageId":"7vhd2chgyg.fsf@assigned-by-dhcp.cox.net","threadId":"4629","inReplyTo":"20060622233752.29122.78856.stgit@machine.or.cz","subject":"Re: [PATCH] Git.pm: Call external commands using execv_git_cmd()","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-06-23T00:08:07Z","receivedAt":"2006-06-23T00:08:07Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Petr Baudis <pasky@suse.cz> writes:\n\n> Instead of explicitly using the git wrapper to call external commands,\n> use the execv_git_cmd() function which will directly call whatever\n> needs to be called. GitBin option becomes useless so drop it.\n\nI think you meant GitPath here.\n"}]}