When exec'ing sub-commands, fall back on execvp (thePATH)
Yeah, that seems to work fine. The theoretical drawback to this approach is that it could possibly effect the order in which the paths are tried. For instance, if a user did "export GIT_EXEC_PATH=", then the builtin_exec_path wouldn't be tried before the PATH. (i doubt that it would be a problem, but thought i should note it)
sRp
----- Original Message -----
Subject: Re: [PATCH] When exec'ing sub-commands, fall back on execvp (thePATH)
Date: Sat, October 20, 2007 0:30
From: "Johannes Schindelin" <[email protected]>
Quoted 27 lines
Hi,
Quoted 23 lines · Scott Parish
exec_cmd.c +3
-3@@ -34,15 +34,15 @@ int execv_git_cmd(const char **argv) {char git_command[PATH_MAX +1 ];int i; +int rc;const char *paths[] = { current_exec_path,getenv (EXEC_PATH_ENVIRONMENT ), builtin_exec_path }; +const char *tmp; +size_t len;for (i =0 ; i <ARRAY_SIZE (paths); ++i) { -size_t len; -int rc;const char *exec_dir = paths[i]; -const char *tmp;if (!exec_dir || !*exec_dir)continue ;
Quoted 7 lines
exec_cmd.c int execv_git_cmd(const char **argv) · line 110
Quoted 7 lines
exec_cmd.c +1
-1@@ -106,8 +106,26 @@ int execv_git_cmd(const char **argv) argv[0 ] = tmp; } -return -1 ; + rc = snprintf(git_command, sizeof(git_command), "git-%s",
argv[0]);
Quoted 2 lines
exec_cmd.c int execv_git_cmd(const char **argv) · line 112
Quoted 2 lines
exec_cmd.c +2
-0+if (rc <0 || rc >=sizeof (git_command) - len) { + fprintf(stderr, "git: command name given is too
long.\n");
Quoted 51 lines
Quoted 7 lines
exec_cmd.c +7
-0+return -1 ; + } + + tmp = argv[0 ]; + argv[0 ] = git_command; + +trace_argv_printf (argv,-1 ,"trace: exec:" );exec_cmd.c int execv_git_cmd(const char **argv) · line 129
Quoted 10 lines
exec_cmd.c +9
-0+ +/* execve() can only ever return if it fails */ +execvp (git_command, (char **)argv); + +trace_printf ("trace: exec failed: %s\n" ,strerror (errno)); + + argv[0 ] = tmp; + +return -1 ; }I am not sure that this is elegant enough: Something like this (completely untested) might be better:
exec_cmd.c +7
-3@@ -36,7 +36,8 @@ int execv_git_cmd(const char **argv)int i;const char *paths[] = { current_exec_path,getenv (EXEC_PATH_ENVIRONMENT ), - builtin_exec_path }; + builtin_exec_path, +"" };for (i =0 ; i <ARRAY_SIZE (paths); ++i) {size_t len;@@ -44,9 +45,12 @@ int execv_git_cmd(const char **argv)const char *exec_dir = paths[i];const char *tmp; -if (!exec_dir || !*exec_dir)continue ; +if (!exec_dir)continue ; -if (*exec_dir !='/' ) { +if (!*exec_dir) +/* try PATH */ + *git_command ='\0' ; +else if (*exec_dir !='/' ) {if (!getcwd (git_command,sizeof (git_command))) { fprintf(stderr, "git: cannot determine " "current directory: %s\n",
exec_cmd.c int execv_git_cmd(const char **argv) · line 87
Quoted 3 lines
exec_cmd.c +0
-0@@ -81,7 +85,7 @@ int execv_git_cmd(const char **argv) len =strlen (git_command); rc = snprintf(git_command + len, sizeof(git_command) -
len,
Quoted 15 lines
exec_cmd.c +1
-1- "/git-%s", argv[0]); + "%sgit-%s", *exec_dir ? "/" : "", argv[0]);if (rc <0 || rc >=sizeof (git_command) - len) {fprintf (stderr,"git: command name given is too long.\n" );Ciao,
Dscho-
To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Actually, i didn't test it right, execve() were using the files in my cwd. In addition to you patch, you'd need to use execvp() instead of execve().
sRp
Quoted 127 lines · Scott R Parish
Yeah, that seems to work fine. The theoretical drawback to this approach is that it could possibly effect the order in which the paths are tried. For instance, if a user did "export GIT_EXEC_PATH=", then the
builtin_exec_pathwouldn't be tried before the PATH. (i doubt that it would be a problem, but thought i should note it)sRp
----- Original Message -----
Subject: Re: [PATCH] When exec'ing sub-commands, fall back on execvp (thePATH)
Date: Sat, October 20, 2007 0:30
From: "Johannes Schindelin" <[email protected]>Quoted 27 lines
Hi,
Quoted 23 lines · Scott Parish
exec_cmd.c +3
-3@@ -34,15 +34,15 @@ int execv_git_cmd(const char **argv) {char git_command[PATH_MAX +1 ];int i; +int rc;const char *paths[] = { current_exec_path,getenv (EXEC_PATH_ENVIRONMENT ), builtin_exec_path }; +const char *tmp; +size_t len;for (i =0 ; i <ARRAY_SIZE (paths); ++i) { -size_t len; -int rc;const char *exec_dir = paths[i]; -const char *tmp;if (!exec_dir || !*exec_dir)continue ;Quoted 7 lines
exec_cmd.c int execv_git_cmd(const char **argv) · line 110
Quoted 7 lines
exec_cmd.c +1
-1@@ -106,8 +106,26 @@ int execv_git_cmd(const char **argv) argv[0 ] = tmp; } -return -1 ; + rc = snprintf(git_command, sizeof(git_command), "git-%s",argv[0]);
Quoted 2 lines
exec_cmd.c int execv_git_cmd(const char **argv) · line 112
Quoted 2 lines
exec_cmd.c +2
-0+if (rc <0 || rc >=sizeof (git_command) - len) { + fprintf(stderr, "git: command name given is toolong.\n");
Quoted 51 lines
Quoted 7 lines
exec_cmd.c +7
-0+return -1 ; + } + + tmp = argv[0 ]; + argv[0 ] = git_command; + +trace_argv_printf (argv,-1 ,"trace: exec:" );exec_cmd.c int execv_git_cmd(const char **argv) · line 129
Quoted 10 lines
exec_cmd.c +9
-0+ +/* execve() can only ever return if it fails */ +execvp (git_command, (char **)argv); + +trace_printf ("trace: exec failed: %s\n" ,strerror (errno)); + + argv[0 ] = tmp; + +return -1 ; }I am not sure that this is elegant enough: Something like this (completely untested) might be better:
exec_cmd.c +7
-3@@ -36,7 +36,8 @@ int execv_git_cmd(const char **argv)int i;const char *paths[] = { current_exec_path,getenv (EXEC_PATH_ENVIRONMENT ), - builtin_exec_path }; + builtin_exec_path, +"" };for (i =0 ; i <ARRAY_SIZE (paths); ++i) {size_t len;@@ -44,9 +45,12 @@ int execv_git_cmd(const char **argv)const char *exec_dir = paths[i];const char *tmp; -if (!exec_dir || !*exec_dir)continue ; +if (!exec_dir)continue ; -if (*exec_dir !='/' ) { +if (!*exec_dir) +/* try PATH */ + *git_command ='\0' ; +else if (*exec_dir !='/' ) {if (!getcwd (git_command,sizeof (git_command))) { fprintf(stderr, "git: cannot determine " "current directory: %s\n",exec_cmd.c int execv_git_cmd(const char **argv) · line 87
Quoted 3 lines
exec_cmd.c +0
-0@@ -81,7 +85,7 @@ int execv_git_cmd(const char **argv) len =strlen (git_command); rc = snprintf(git_command + len, sizeof(git_command) -len,
Quoted 6 lines
exec_cmd.c +1
-1- "/git-%s", argv[0]); + "%sgit-%s", *exec_dir ? "/" : "", argv[0]);if (rc <0 || rc >=sizeof (git_command) - len) {fprintf (stderr,"git: command name given is too long.\n" );Quoted 9 lines
Ciao,
Dscho-
To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html-
To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Scott Parish http://srparish.net/
PATCH 1/1 execv_git_cmd(): also try PATH if everything else fails.
Earlier, we tried to find the git commands in several possible exec dirs. Now, if all of these failed, try to find the git command in PATH.
This allows you to install the git programs somewhere else than originally specified when building git, as long as you add that location to the PATH.
Initial implementation by Scott R Parish.
---
On Sat, 20 Oct 2007, Scott Parish wrote:
> Actually, i didn't test it right, execve() were using the files > in my cwd. In addition to you patch, you'd need to use execvp() > instead of execve().
Ah, right. I missed that one ;-)
How about this instead?
exec_cmd.c | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-)
exec_cmd.c +8 -4
@@ -36,7 +36,8 @@ int execv_git_cmd(const char **argv)int i;const char *paths[] = { current_exec_path,getenv (EXEC_PATH_ENVIRONMENT ), - builtin_exec_path }; + builtin_exec_path, +"" };for (i =0 ; i <ARRAY_SIZE (paths); ++i) {size_t len;
@@ -44,9 +45,12 @@ int execv_git_cmd(const char **argv)const char *exec_dir = paths[i];const char *tmp; -if (!exec_dir || !*exec_dir)continue ; +if (!exec_dir)continue ; -if (*exec_dir !='/' ) { +if (!*exec_dir) +/* try PATH */ + *git_command ='\0' ; +else if (*exec_dir !='/' ) {if (!getcwd (git_command,sizeof (git_command))) { fprintf(stderr, "git: cannot determine " "current directory: %s\n",
@@ -81,7 +85,7 @@ int execv_git_cmd(const char **argv) len =strlen (git_command); rc =snprintf (git_command + len,sizeof (git_command) - len, -"/git-%s" , argv[0 ]); +"%sgit-%s" , *exec_dir ?"/" :"" , argv[0 ]);if (rc <0 || rc >=sizeof (git_command) - len) {fprintf (stderr,"git: command name given is too long.\n" );
Signature · 1 line
1.5.3.4.1287.g8b31e
Re: [PATCH] execv_git_cmd(): also try PATH if everything else fails.
Quoted 9 lines · Johannes Schindelin
On Sat, 20 Oct 2007, Scott Parish wrote:
> Actually, i didn't test it right,
execve()were using the files > in my cwd. In addition to you patch, you'd need to useexecvp()> instead ofexecve().Ah, right. I missed that one ;-)
How about this instead?
Uhhh. Its the same, isn't it? Still using execve() which means we will not look at PATH in the final attempt.
Quoted 43 lines
exec_cmd.c | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-)exec_cmd.c +8
-4@@ -36,7 +36,8 @@ int execv_git_cmd(const char **argv)int i;const char *paths[] = { current_exec_path,getenv (EXEC_PATH_ENVIRONMENT ), - builtin_exec_path }; + builtin_exec_path, +"" };for (i =0 ; i <ARRAY_SIZE (paths); ++i) {size_t len;@@ -44,9 +45,12 @@ int execv_git_cmd(const char **argv)const char *exec_dir = paths[i];const char *tmp; -if (!exec_dir || !*exec_dir)continue ; +if (!exec_dir)continue ; -if (*exec_dir !='/' ) { +if (!*exec_dir) +/* try PATH */ + *git_command ='\0' ; +else if (*exec_dir !='/' ) {if (!getcwd (git_command,sizeof (git_command))) { fprintf(stderr, "git: cannot determine " "current directory: %s\n",@@ -81,7 +85,7 @@ int execv_git_cmd(const char **argv) len =strlen (git_command); rc =snprintf (git_command + len,sizeof (git_command) - len, -"/git-%s" , argv[0 ]); +"%sgit-%s" , *exec_dir ?"/" :"" , argv[0 ]);if (rc <0 || rc >=sizeof (git_command) - len) {fprintf (stderr,"git: command name given is too long.\n" );Signature · 1 line
1.5.3.4.1287.g8b31e
Signature · 1 line
Shawn.
PATCH 1/1 execv_git_cmd(): also try PATH if everything else fails.
Earlier, we tried to find the git commands in several possible exec dirs. Now, if all of these failed, try to find the git command in PATH.
This allows you to install the git programs somewhere else than originally specified when building git, as long as you add that location to the PATH.
Initial implementation by Scott R Parish.
---
On Sat, 20 Oct 2007, Shawn O. Pearce wrote:
> Johannes Schindelin <[email protected]> wrote:
> > On Sat, 20 Oct 2007, Scott Parish wrote:
> >
> > > Actually, i didn't test it right, execve() were using the > > > files in my cwd. In addition to you patch, you'd need to use > > > execvp() instead of execve().
> >
> > Ah, right. I missed that one ;-)
> >
> > How about this instead?
>
> Uhhh. Its the same, isn't it? Still using execve() which means > we will not look at PATH in the final attempt.
Sorry. I forgot to --amend.
exec_cmd.c | 17 ++++++++++++----- 1 files changed, 12 insertions(+), 5 deletions(-)
exec_cmd.c +12 -5
@@ -36,7 +36,8 @@ int execv_git_cmd(const char **argv)int i;const char *paths[] = { current_exec_path,getenv (EXEC_PATH_ENVIRONMENT ), - builtin_exec_path }; + builtin_exec_path, +"" };for (i =0 ; i <ARRAY_SIZE (paths); ++i) {size_t len;
@@ -44,9 +45,12 @@ int execv_git_cmd(const char **argv)const char *exec_dir = paths[i];const char *tmp; -if (!exec_dir || !*exec_dir)continue ; +if (!exec_dir)continue ; -if (*exec_dir !='/' ) { +if (!*exec_dir) +/* try PATH */ + *git_command ='\0' ; +else if (*exec_dir !='/' ) {if (!getcwd (git_command,sizeof (git_command))) { fprintf(stderr, "git: cannot determine " "current directory: %s\n",
@@ -81,7 +85,7 @@ int execv_git_cmd(const char **argv) len =strlen (git_command); rc =snprintf (git_command + len,sizeof (git_command) - len, -"/git-%s" , argv[0 ]); +"%sgit-%s" , *exec_dir ?"/" :"" , argv[0 ]);if (rc <0 || rc >=sizeof (git_command) - len) {fprintf (stderr,"git: command name given is too long.\n" );
@@ -100,7 +104,10 @@ int execv_git_cmd(const char **argv)trace_argv_printf (argv,-1 ,"trace: exec:" );/* execve() can only ever return if it fails */ -execve (git_command, (char **)argv, environ); +if (*exec_dir) +execve (git_command, (char **)argv, environ); +else +execvp (git_command, (char **)argv);trace_printf ("trace: exec failed: %s\n" ,strerror (errno));
Signature · 1 line
1.5.3.4.1289.ga1432
Re: [PATCH] execv_git_cmd(): also try PATH if everything else fails.
Quoted 3 lines · Johannes Schindelin
Earlier, we tried to find the git commands in several possible exec dirs. Now, if all of these failed, try to find the git command in PATH.
...
exec_cmd.c int execv_git_cmd(const char **argv) · line 40
Quoted 11 lines
exec_cmd.c +2
-1@@ -36,7 +36,8 @@ int execv_git_cmd(const char **argv)int i;const char *paths[] = { current_exec_path,getenv (EXEC_PATH_ENVIRONMENT ), - builtin_exec_path }; + builtin_exec_path, +"" };
So if the user sets GIT_EXEC_PATH="" and exports it we'll search $PATH before the builtin exec path that Git was compiled with? Are we sure we want to do that?
I'm going to throw this into pu tonight just so I don't lose it, but I have a feeling we want to amend it before merging.
Signature · 1 line
Shawn.
Re: [PATCH] execv_git_cmd(): also try PATH if everything else fails.
Hi,
Quoted 5 lines · Shawn O. Pearce
Quoted 3 lines · Johannes Schindelin
Earlier, we tried to find the git commands in several possible exec dirs. Now, if all of these failed, try to find the git command in PATH.
...
Quoted 15 lines
exec_cmd.c int execv_git_cmd(const char **argv) · line 40
Quoted 11 lines
exec_cmd.c +2
-1@@ -36,7 +36,8 @@ int execv_git_cmd(const char **argv)int i;const char *paths[] = { current_exec_path,getenv (EXEC_PATH_ENVIRONMENT ), - builtin_exec_path }; + builtin_exec_path, +"" };So if the user sets GIT_EXEC_PATH="" and exports it we'll search $PATH before the builtin exec path that Git was compiled with? Are we sure we want to do that?
I thought the proper way to unset EXEC_PATH was to "unset GIT_EXEC_PATH". In that case, getenv(EXEC_PATH_ENVIRONMENT) returns NULL and we're fine, no?
Ciao,
Dscho
Re: [PATCH] execv_git_cmd(): also try PATH if everything else fails.
Quoted 22 lines · Johannes Schindelin
Quoted 5 lines · Shawn O. Pearce
Quoted 3 lines · Johannes Schindelin
Earlier, we tried to find the git commands in several possible exec dirs. Now, if all of these failed, try to find the git command in PATH.
...
Quoted 15 lines
exec_cmd.c int execv_git_cmd(const char **argv) · line 40
Quoted 11 lines
exec_cmd.c +2
-1@@ -36,7 +36,8 @@ int execv_git_cmd(const char **argv)int i;const char *paths[] = { current_exec_path,getenv (EXEC_PATH_ENVIRONMENT ), - builtin_exec_path }; + builtin_exec_path, +"" };So if the user sets GIT_EXEC_PATH="" and exports it we'll search $PATH before the builtin exec path that Git was compiled with? Are we sure we want to do that?
Quoted 3 lines
I thought the proper way to unset
EXEC_PATHwas to "unsetGIT_EXEC_PATH". In that case,getenv(EXEC_PATH_ENVIRONMENT)returns NULL and we're fine, no?
Sure. But can't you also export an environment variable that is set to the empty string? At least on UNIX. Windows thinks unset and empty string are the same thing.
Signature · 1 line
Shawn.
Re: [PATCH] execv_git_cmd(): also try PATH if everything else fails.
Hi,
Quoted 23 lines · Shawn O. Pearce
Quoted 22 lines · Johannes Schindelin
Quoted 20 lines · Shawn O. Pearce
Quoted 3 lines · Johannes Schindelin
Earlier, we tried to find the git commands in several possible exec dirs. Now, if all of these failed, try to find the git command in PATH.
...
exec_cmd.c int execv_git_cmd(const char **argv) · line 40
Quoted 11 lines
exec_cmd.c +2
-1@@ -36,7 +36,8 @@ int execv_git_cmd(const char **argv)int i;const char *paths[] = { current_exec_path,getenv (EXEC_PATH_ENVIRONMENT ), - builtin_exec_path }; + builtin_exec_path, +"" };So if the user sets GIT_EXEC_PATH="" and exports it we'll search $PATH before the builtin exec path that Git was compiled with? Are we sure we want to do that?
Quoted 7 lines
Quoted 3 lines
I thought the proper way to unset
EXEC_PATHwas to "unsetGIT_EXEC_PATH". In that case,getenv(EXEC_PATH_ENVIRONMENT)returns NULL and we're fine, no?Sure. But can't you also export an environment variable that is set to the empty string? At least on UNIX. Windows thinks unset and empty string are the same thing.
Not here. I just tried (with msysGit, of course).
Anyway, I like the other patch Scott sent much more than mine, which offloads the work to execvp().
Ciao,
Dscho
Re: [PATCH] execv_git_cmd(): also try PATH if everything else fails.
In reply to Johannes SchindelinQuoted 3 lines · Johannes Schindelin
Earlier, we tried to find the git commands in several possible exec dirs. Now, if all of these failed, try to find the git command in PATH.
I'm tempted to try a different approach. What if instead of looping and building up strings of all the different absolute paths we want to try we just prepend to PATH with the correct extra precedence, and then call execvp on the command we want?
sRp
Signature · 2 lines
Scott Parish http://srparish.net/
Re: [PATCH] execv_git_cmd(): also try PATH if everything else fails.
Quoted 11 lines · Scott Parish
Quoted 3 lines · Johannes Schindelin
Earlier, we tried to find the git commands in several possible exec dirs. Now, if all of these failed, try to find the git command in PATH.
I'm tempted to try a different approach. What if instead of looping and building up strings of all the different absolute paths we want to try we just prepend to PATH with the correct extra precedence, and then call execvp on the command we want?
That's how the original git --exec-dir feature got implemented. There's even a nifty function for it in git.c; prepend_to_path(). It's a provably workable solution.
Signature · 3 lines
Andreas Ericsson [email protected] OP5 AB www.op5.se Tel: +46 8-230225 Fax: +46 8-230231
Re: [PATCH] execv_git_cmd(): also try PATH if everything else fails.
Quoted 8 lines · Andreas Ericsson
Quoted 5 lines · Scott Parish
I'm tempted to try a different approach. What if instead of looping and building up strings of all the different absolute paths we want to try we just prepend to PATH with the correct extra precedence, and then call execvp on the command we want?
That's how the original git --exec-dir feature got implemented. There's even a nifty function for it in
git.c;prepend_to_path(). It's a provably workable solution.
The reason that this was done is for the sake of shell scripts: They need to have the path that was finally decided as exec-path in $PATH.
But I can't think of any negative side effect if *all* exec-path candidates are in $PATH. It's important, though, that all paths are absolute because the tools chdir every now and then.
-- Hannes
Re: [PATCH] execv_git_cmd(): also try PATH if everything else fails.
Quoted 8 lines · Johannes Sixt
Quoted 7 lines · Andreas Ericsson
Quoted 5 lines · Scott Parish
I'm tempted to try a different approach. What if instead of looping and building up strings of all the different absolute paths we want to try we just prepend to PATH with the correct extra precedence, and then call execvp on the command we want?
Quoted 6 lines
Quoted 1 line
That's how the original git --exec-dir feature got implemented. There's even a nifty function for it in
git.c;prepend_to_path(). It's a provably workable solution.The reason that this was done is for the sake of shell scripts: They need to have the path that was finally decided as exec-path in $PATH.
But I can't think of any negative side effect if *all* exec-path candidates are in $PATH. It's important, though, that all paths are absolute because the tools chdir every now and then.
So long as they're added in "success:failed:failed" order, I don't see any issues either. Assuming we stop prepending once we find something that works, that should be a non-issue.
Signature · 3 lines
Andreas Ericsson [email protected] OP5 AB www.op5.se Tel: +46 8-230225 Fax: +46 8-230231
Re: [PATCH] execv_git_cmd(): also try PATH if everything else fails.
Quoted 7 lines · Andreas Ericsson
Quoted 2 lines · Johannes Sixt
But I can't think of any negative side effect if *all* exec-path candidates are in $PATH. It's important, though, that all paths are absolute because the tools chdir every now and then.
So long as they're added in "success:failed:failed" order, I don't see any issues either. Assuming we stop prepending once we find something that works, that should be a non-issue.
No, the point is exactly to let execvp() do all the work and we don't care which of the paths is the "success". And I don't think that this has any negative side effects.
-- Hannes
Re: [PATCH] execv_git_cmd(): also try PATH if everything else fails.
In reply to Johannes SchindelinEarlier, we tried to find the git commands in several possible exec dirs. Now, if all of these failed, try to find the git command in PATH.
This allows you to install the git programs somewhere else than originally specified when building git, as long as you add that location to the PATH.
Implementation by Johannes Schindelin
--- exec_cmd.c | 16 ++++++++++------ 1 files changed, 10 insertions(+), 6 deletions(-)
exec_cmd.c +10 -6
@@ -36,7 +36,8 @@ int execv_git_cmd(const char **argv)int i;const char *paths[] = { current_exec_path,getenv (EXEC_PATH_ENVIRONMENT ), - builtin_exec_path }; + builtin_exec_path, +"" };for (i =0 ; i <ARRAY_SIZE (paths); ++i) {size_t len;
@@ -44,9 +45,12 @@ int execv_git_cmd(const char **argv)const char *exec_dir = paths[i];const char *tmp; -if (!exec_dir || !*exec_dir)continue ; +if (!exec_dir)continue ; -if (*exec_dir !='/' ) { +if (!*exec_dir) +/* try PATH */ + *git_command ='\0' ; +else if (*exec_dir !='/' ) {if (!getcwd (git_command,sizeof (git_command))) { fprintf(stderr, "git: cannot determine " "current directory: %s\n",
@@ -81,7 +85,7 @@ int execv_git_cmd(const char **argv) len =strlen (git_command); rc =snprintf (git_command + len,sizeof (git_command) - len, -"/git-%s" , argv[0 ]); +"%sgit-%s" , *exec_dir ?"/" :"" , argv[0 ]);if (rc <0 || rc >=sizeof (git_command) - len) {fprintf (stderr,"git: command name given is too long.\n" );
@@ -99,8 +103,8 @@ int execv_git_cmd(const char **argv)trace_argv_printf (argv,-1 ,"trace: exec:" ); -/* execve() can only ever return if it fails */ -execve (git_command, (char **)argv, environ); +/* execvp() can only ever return if it fails */ +execvp (git_command, (char **)argv);trace_printf ("trace: exec failed: %s\n" ,strerror (errno));
Signature · 1 line
1.5.3.4.206.g58ba4-dirty
Re: [PATCH] execv_git_cmd(): also try PATH if everything else fails.
Hi,
exec_cmd.c int execv_git_cmd(const char **argv) · line 107
Quoted 12 lines · Scott Parish
exec_cmd.c +2
-2@@ -99,8 +103,8 @@ int execv_git_cmd(const char **argv)trace_argv_printf (argv,-1 ,"trace: exec:" ); -/* execve() can only ever return if it fails */ -execve (git_command, (char **)argv, environ); +/* execvp() can only ever return if it fails */ +execvp (git_command, (char **)argv);
I'd rather have it conditional upon *exec_dir (see the brown paper bag patch I just sent).
Ciao,
Dscho
Hi,
[please do not top post. Just delete everything you do not reply to, and put your answers below the text you are replying to. This spares others so much time.]
Quoted 5 lines · Scott R Parish
The theoretical drawback to this approach is that it could possibly effect the order in which the paths are tried. For instance, if a user did "export GIT_EXEC_PATH=", then the
builtin_exec_pathwouldn't be tried before the PATH. (i doubt that it would be a problem, but thought i should note it)
In that respect, my code does not change anything from your code.
Ciao,
Dscho