{"thread":{"id":"10431","subject":"[PATCH] use only the PATH for exec'ing git commands","startedAt":"2007-10-22T17:01:48Z","lastAt":"2007-10-23T21:27:42Z","messageCount":7,"participants":["Scott R Parish","Johannes Schindelin","Alex Riesen","Eric Merritt","Scott Parish"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"56896","messageId":"20071022170148.GB29642@srparish.net","threadId":"10431","inReplyTo":null,"subject":"[PATCH] use only the PATH for exec'ing git commands","fromName":"Scott R Parish","fromEmail":"srp@srparish.net","sentAt":"2007-10-22T17:01:48Z","receivedAt":"2007-10-22T17:01:48Z","isPatch":true,"sender":{"key":"srp@srparish.net","avatar":"https://gravatar.com/avatar/870e5b6fc4f710cf4db5684bd9af7f2cee5734b3dab3209b13e00cf64f6c9f0e?d=mp&s=160"},"body":"We need to correctly set up PATH for non-c based git commands. Since we\nalready do this, we can just use that PATH and execvp, instead of looping\nover the paths with execve.\n\nThis patch adds a setup_path() function to exec_cmd.c, which sets\nthe PATH order correctly for our search order. execv_git_cmd() is\nstripped down to setting up argv and calling execvp(). git.c's main()\nonly only needs to call setup_path().\n\nSigned-off-by: Scott R Parish <srp@srparish.net>\n---\n exec_cmd.c |  122 ++++++++++++++++++++++++++----------------------------------\n exec_cmd.h |    1 +\n git.c      |   43 +++------------------\n 3 files changed, 61 insertions(+), 105 deletions(-)\n\ndiff --git a/exec_cmd.c b/exec_cmd.c\nindex 8b681d0..b154c24 100644\n--- a/exec_cmd.c\n+++ b/exec_cmd.c\n@@ -29,85 +29,69 @@ const char *git_exec_path(void)\n \treturn builtin_exec_path;\n }\n \n+static void add_path(struct strbuf *out, const char *path)\n+{\n+\tif (path && strlen(path)) {\n+\t\tif (is_absolute_path(path))\n+\t\t\tstrbuf_addstr(out, path);\n+\t\telse\n+\t\t\tstrbuf_addstr(out, make_absolute_path(path));\n+\n+\t\tstrbuf_addch(out, ':');\n+\t}\n+}\n+\n+void setup_path(const char *cmd_path)\n+{\n+\tconst char *old_path = getenv(\"PATH\");\n+\tstruct strbuf new_path;\n+\n+\tstrbuf_init(&new_path, 0);\n+\n+\tadd_path(&new_path, argv_exec_path);\n+\tadd_path(&new_path, getenv(EXEC_PATH_ENVIRONMENT));\n+\tadd_path(&new_path, builtin_exec_path);\n+\tadd_path(&new_path, cmd_path);\n+\t\t\n+\tif (old_path)\n+\t\tstrbuf_addstr(&new_path, old_path);\n+\telse \n+\t\tstrbuf_addstr(&new_path, \"/usr/local/bin:/usr/bin:/bin\");\n+\n+\tsetenv(\"PATH\", new_path.buf, 1);\n+\n+\tstrbuf_release(&new_path);\n+}\n+\n \n int execv_git_cmd(const char **argv)\n {\n-\tchar git_command[PATH_MAX + 1];\n-\tint i;\n-\tconst char *paths[] = { argv_exec_path,\n-\t\t\t\tgetenv(EXEC_PATH_ENVIRONMENT),\n-\t\t\t\tbuiltin_exec_path };\n-\n-\tfor (i = 0; i < ARRAY_SIZE(paths); ++i) {\n-\t\tsize_t len;\n-\t\tint rc;\n-\t\tconst char *exec_dir = paths[i];\n-\t\tconst char *tmp;\n-\n-\t\tif (!exec_dir || !*exec_dir) continue;\n-\n-\t\tif (*exec_dir != '/') {\n-\t\t\tif (!getcwd(git_command, sizeof(git_command))) {\n-\t\t\t\tfprintf(stderr, \"git: cannot determine \"\n-\t\t\t\t\t\"current directory: %s\\n\",\n-\t\t\t\t\tstrerror(errno));\n-\t\t\t\tbreak;\n-\t\t\t}\n-\t\t\tlen = strlen(git_command);\n-\n-\t\t\t/* Trivial cleanup */\n-\t\t\twhile (!prefixcmp(exec_dir, \"./\")) {\n-\t\t\t\texec_dir += 2;\n-\t\t\t\twhile (*exec_dir == '/')\n-\t\t\t\t\texec_dir++;\n-\t\t\t}\n-\n-\t\t\trc = snprintf(git_command + len,\n-\t\t\t\t      sizeof(git_command) - len, \"/%s\",\n-\t\t\t\t      exec_dir);\n-\t\t\tif (rc < 0 || rc >= sizeof(git_command) - len) {\n-\t\t\t\tfprintf(stderr, \"git: command name given \"\n-\t\t\t\t\t\"is too long.\\n\");\n-\t\t\t\tbreak;\n-\t\t\t}\n-\t\t} else {\n-\t\t\tif (strlen(exec_dir) + 1 > sizeof(git_command)) {\n-\t\t\t\tfprintf(stderr, \"git: command name given \"\n-\t\t\t\t\t\"is too long.\\n\");\n-\t\t\t\tbreak;\n-\t\t\t}\n-\t\t\tstrcpy(git_command, exec_dir);\n-\t\t}\n-\n-\t\tlen = strlen(git_command);\n-\t\trc = snprintf(git_command + len, sizeof(git_command) - len,\n-\t\t\t      \"/git-%s\", argv[0]);\n-\t\tif (rc < 0 || rc >= sizeof(git_command) - len) {\n-\t\t\tfprintf(stderr,\n-\t\t\t\t\"git: command name given is too long.\\n\");\n-\t\t\tbreak;\n-\t\t}\n+\tstruct strbuf cmd;\n+\tconst char *tmp;\n \n-\t\t/* argv[0] must be the git command, but the argv array\n-\t\t * belongs to the caller, and my be reused in\n-\t\t * subsequent loop iterations. Save argv[0] and\n-\t\t * restore it on error.\n-\t\t */\n+\tstrbuf_init(&cmd, 0);\n+\tstrbuf_addf(&cmd, \"git-%s\", argv[0]);\n \n-\t\ttmp = argv[0];\n-\t\targv[0] = git_command;\n+\t/* argv[0] must be the git command, but the argv array\n+\t * belongs to the caller, and my be reused in\n+\t * subsequent loop iterations. Save argv[0] and\n+\t * restore it on error.\n+\t */\n+\ttmp = argv[0];\n+\targv[0] = cmd.buf;\n \n-\t\ttrace_argv_printf(argv, -1, \"trace: exec:\");\n+\ttrace_argv_printf(argv, -1, \"trace: exec:\");\n \n-\t\t/* execve() can only ever return if it fails */\n-\t\texecve(git_command, (char **)argv, environ);\n+\t/* execvp() can only ever return if it fails */\n+\texecvp(cmd.buf, (char **)argv);\n \n-\t\ttrace_printf(\"trace: exec failed: %s\\n\", strerror(errno));\n+\ttrace_printf(\"trace: exec failed: %s\\n\", strerror(errno));\n \n-\t\targv[0] = tmp;\n-\t}\n-\treturn -1;\n+\targv[0] = tmp;\n \n+\tstrbuf_release(&cmd);\n+\n+\treturn -1;\n }\n \n \ndiff --git a/exec_cmd.h b/exec_cmd.h\nindex da99287..a892355 100644\n--- a/exec_cmd.h\n+++ b/exec_cmd.h\n@@ -3,6 +3,7 @@\n \n extern void git_set_argv_exec_path(const char *exec_path);\n extern const char* git_exec_path(void);\n+extern void setup_path(const char *);\n extern int execv_git_cmd(const char **argv); /* NULL terminated */\n extern int execl_git_cmd(const char *cmd, ...);\n \ndiff --git a/git.c b/git.c\nindex f659338..a639e42 100644\n--- a/git.c\n+++ b/git.c\n@@ -6,28 +6,6 @@\n const char git_usage_string[] =\n \t\"git [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate|--no-pager] [--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE] [--help] COMMAND [ARGS]\";\n \n-static void prepend_to_path(const char *dir, int len)\n-{\n-\tconst char *old_path = getenv(\"PATH\");\n-\tchar *path;\n-\tint path_len = len;\n-\n-\tif (!old_path)\n-\t\told_path = \"/usr/local/bin:/usr/bin:/bin\";\n-\n-\tpath_len = len + strlen(old_path) + 1;\n-\n-\tpath = xmalloc(path_len + 1);\n-\n-\tmemcpy(path, dir, len);\n-\tpath[len] = ':';\n-\tmemcpy(path + len + 1, old_path, path_len - len);\n-\n-\tsetenv(\"PATH\", path, 1);\n-\n-\tfree(path);\n-}\n-\n static int handle_options(const char*** argv, int* argc, int* envchanged)\n {\n \tint handled = 0;\n@@ -403,7 +381,7 @@ int main(int argc, const char **argv)\n {\n \tconst char *cmd = argv[0] ? argv[0] : \"git-help\";\n \tchar *slash = strrchr(cmd, '/');\n-\tconst char *exec_path = NULL;\n+\tconst char *cmd_path = NULL;\n \tint done_alias = 0;\n \n \t/*\n@@ -413,10 +391,7 @@ int main(int argc, const char **argv)\n \t */\n \tif (slash) {\n \t\t*slash++ = 0;\n-\t\tif (*cmd == '/')\n-\t\t\texec_path = cmd;\n-\t\telse\n-\t\t\texec_path = xstrdup(make_absolute_path(cmd));\n+\t\tcmd_path = cmd;\n \t\tcmd = slash;\n \t}\n \n@@ -451,16 +426,12 @@ int main(int argc, const char **argv)\n \tcmd = argv[0];\n \n \t/*\n-\t * We execute external git command via execv_git_cmd(),\n-\t * which looks at \"--exec-path\" option, GIT_EXEC_PATH\n-\t * environment, and $(gitexecdir) in Makefile while built,\n-\t * in this order.  For scripted commands, we prepend\n-\t * the value of the exec_path variable to the PATH.\n+\t * We use PATH to find git commands, but we prepend some higher\n+\t * precidence paths: the \"--exec-path\" option, the GIT_EXEC_PATH\n+\t * environment, and the $(gitexecdir) from the Makefile at build\n+\t * time.\n \t */\n-\tif (exec_path)\n-\t\tprepend_to_path(exec_path, strlen(exec_path));\n-\texec_path = git_exec_path();\n-\tprepend_to_path(exec_path, strlen(exec_path));\n+\tsetup_path(cmd_path);\n \n \twhile (1) {\n \t\t/* See if it's an internal command */\n-- \ngitgui.0.8.4.11176.gd9205-dirty\n"},{"id":"56899","messageId":"Pine.LNX.4.64.0710221843590.25221@racer.site","threadId":"10431","inReplyTo":"20071022170148.GB29642@srparish.net","subject":"Re: [PATCH] use only the PATH for exec'ing git commands","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-10-22T17:44:20Z","receivedAt":"2007-10-22T17:44:20Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 22 Oct 2007, Scott R Parish wrote:\n\n>  3 files changed, 61 insertions(+), 105 deletions(-)\n\nNice.\n\nCiao,\nDscho\n"},{"id":"56904","messageId":"20071022190102.GA23714@steel.home","threadId":"10431","inReplyTo":"20071022170148.GB29642@srparish.net","subject":"Re: [PATCH] use only the PATH for exec'ing git commands","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-10-22T19:01:02Z","receivedAt":"2007-10-22T19:01:02Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Scott R Parish, Mon, Oct 22, 2007 19:01:48 +0200:\n> +static void add_path(struct strbuf *out, const char *path)\n> +{\n> +\tif (path && strlen(path)) {\n> +\t\tif (is_absolute_path(path))\n> +\t\t\tstrbuf_addstr(out, path);\n> +\t\telse\n> +\t\t\tstrbuf_addstr(out, make_absolute_path(path));\n> +\n> +\t\tstrbuf_addch(out, ':');\n\nShouldn't it break MingW32 native port?\n\n> +\t}\n> +}\n> +\n> +void setup_path(const char *cmd_path)\n> +{\n> +\tconst char *old_path = getenv(\"PATH\");\n> +\tstruct strbuf new_path;\n> +\n> +\tstrbuf_init(&new_path, 0);\n> +\n> +\tadd_path(&new_path, argv_exec_path);\n> +\tadd_path(&new_path, getenv(EXEC_PATH_ENVIRONMENT));\n> +\tadd_path(&new_path, builtin_exec_path);\n> +\tadd_path(&new_path, cmd_path);\n> +\t\t\n\ntrailing space\n\n> +\tif (old_path)\n> +\t\tstrbuf_addstr(&new_path, old_path);\n> +\telse \n> +\t\tstrbuf_addstr(&new_path, \"/usr/local/bin:/usr/bin:/bin\");\n\nthe default PATH is platform-dependent. Git is multi-platform.\nYou should consider putting the path list somewhere in Makefile,\nconfig.mak or configure.\n\n> +\n> +\tsetenv(\"PATH\", new_path.buf, 1);\n"},{"id":"56906","messageId":"f69c840c0710221225u5df73cf9x7f95ea3bd530c160@mail.gmail.com","threadId":"10431","inReplyTo":"20071022190102.GA23714@steel.home","subject":"Re: [PATCH] use only the PATH for exec'ing git commands","fromName":"Eric Merritt","fromEmail":"cyberlync@gmail.com","sentAt":"2007-10-22T19:25:21Z","receivedAt":"2007-10-22T19:25:21Z","isPatch":true,"sender":{"key":"cyberlync@gmail.com","avatar":null},"body":"> the default PATH is platform-dependent. Git is multi-platform.\n> You should consider putting the path list somewhere in Makefile,\n> config.mak or configure.\n\nThis static configuration that you describe is one of the things this\npatch is designed to strip out. Compile time configuration breaks down\ncompletly if you don't deploy to the path defined when the system was\ncompiled. Thats a problem.\n"},{"id":"56949","messageId":"20071023040844.GQ16291@srparish.net","threadId":"10431","inReplyTo":"20071022190102.GA23714@steel.home","subject":"[PATCH trailing ws fixed] use only the PATH for exec'ing git commands","fromName":"Scott Parish","fromEmail":"srp@srparish.net","sentAt":"2007-10-23T04:08:45Z","receivedAt":"2007-10-23T04:08:45Z","isPatch":true,"sender":{"key":"srp@srparish.net","avatar":"https://gravatar.com/avatar/870e5b6fc4f710cf4db5684bd9af7f2cee5734b3dab3209b13e00cf64f6c9f0e?d=mp&s=160"},"body":"We need to correctly set up PATH for non-c based git commands. Since we\nalready do this, we can just use that PATH and execvp, instead of looping\nover the paths with execve.\n\nThis patch adds a setup_path() function to exec_cmd.c, which sets\nthe PATH order correctly for our search order. execv_git_cmd() is\nstripped down to setting up argv and calling execvp(). git.c's main()\nonly only needs to call setup_path().\n\nSigned-off-by: Scott R Parish <srp@srparish.net>\n---\n exec_cmd.c |  121 ++++++++++++++++++++++++++----------------------------------\n exec_cmd.h |    1 +\n git.c      |   43 +++------------------\n 3 files changed, 60 insertions(+), 105 deletions(-)\n\ndiff --git a/exec_cmd.c b/exec_cmd.c\nindex 8b681d0..c228dbf 100644\n--- a/exec_cmd.c\n+++ b/exec_cmd.c\n@@ -29,85 +29,68 @@ const char *git_exec_path(void)\n \treturn builtin_exec_path;\n }\n \n+static void add_path(struct strbuf *out, const char *path)\n+{\n+\tif (path && strlen(path)) {\n+\t\tif (is_absolute_path(path))\n+\t\t\tstrbuf_addstr(out, path);\n+\t\telse\n+\t\t\tstrbuf_addstr(out, make_absolute_path(path));\n+\n+\t\tstrbuf_addch(out, ':');\n+\t}\n+}\n+\n+void setup_path(const char *cmd_path)\n+{\n+\tconst char *old_path = getenv(\"PATH\");\n+\tstruct strbuf new_path;\n+\n+\tstrbuf_init(&new_path, 0);\n+\n+\tadd_path(&new_path, argv_exec_path);\n+\tadd_path(&new_path, getenv(EXEC_PATH_ENVIRONMENT));\n+\tadd_path(&new_path, builtin_exec_path);\n+\tadd_path(&new_path, cmd_path);\n+\n+\tif (old_path)\n+\t\tstrbuf_addstr(&new_path, old_path);\n+\telse\n+\t\tstrbuf_addstr(&new_path, \"/usr/local/bin:/usr/bin:/bin\");\n+\n+\tsetenv(\"PATH\", new_path.buf, 1);\n+\n+\tstrbuf_release(&new_path);\n+}\n \n int execv_git_cmd(const char **argv)\n {\n-\tchar git_command[PATH_MAX + 1];\n-\tint i;\n-\tconst char *paths[] = { argv_exec_path,\n-\t\t\t\tgetenv(EXEC_PATH_ENVIRONMENT),\n-\t\t\t\tbuiltin_exec_path };\n-\n-\tfor (i = 0; i < ARRAY_SIZE(paths); ++i) {\n-\t\tsize_t len;\n-\t\tint rc;\n-\t\tconst char *exec_dir = paths[i];\n-\t\tconst char *tmp;\n-\n-\t\tif (!exec_dir || !*exec_dir) continue;\n-\n-\t\tif (*exec_dir != '/') {\n-\t\t\tif (!getcwd(git_command, sizeof(git_command))) {\n-\t\t\t\tfprintf(stderr, \"git: cannot determine \"\n-\t\t\t\t\t\"current directory: %s\\n\",\n-\t\t\t\t\tstrerror(errno));\n-\t\t\t\tbreak;\n-\t\t\t}\n-\t\t\tlen = strlen(git_command);\n-\n-\t\t\t/* Trivial cleanup */\n-\t\t\twhile (!prefixcmp(exec_dir, \"./\")) {\n-\t\t\t\texec_dir += 2;\n-\t\t\t\twhile (*exec_dir == '/')\n-\t\t\t\t\texec_dir++;\n-\t\t\t}\n-\n-\t\t\trc = snprintf(git_command + len,\n-\t\t\t\t      sizeof(git_command) - len, \"/%s\",\n-\t\t\t\t      exec_dir);\n-\t\t\tif (rc < 0 || rc >= sizeof(git_command) - len) {\n-\t\t\t\tfprintf(stderr, \"git: command name given \"\n-\t\t\t\t\t\"is too long.\\n\");\n-\t\t\t\tbreak;\n-\t\t\t}\n-\t\t} else {\n-\t\t\tif (strlen(exec_dir) + 1 > sizeof(git_command)) {\n-\t\t\t\tfprintf(stderr, \"git: command name given \"\n-\t\t\t\t\t\"is too long.\\n\");\n-\t\t\t\tbreak;\n-\t\t\t}\n-\t\t\tstrcpy(git_command, exec_dir);\n-\t\t}\n-\n-\t\tlen = strlen(git_command);\n-\t\trc = snprintf(git_command + len, sizeof(git_command) - len,\n-\t\t\t      \"/git-%s\", argv[0]);\n-\t\tif (rc < 0 || rc >= sizeof(git_command) - len) {\n-\t\t\tfprintf(stderr,\n-\t\t\t\t\"git: command name given is too long.\\n\");\n-\t\t\tbreak;\n-\t\t}\n+\tstruct strbuf cmd;\n+\tconst char *tmp;\n \n-\t\t/* argv[0] must be the git command, but the argv array\n-\t\t * belongs to the caller, and my be reused in\n-\t\t * subsequent loop iterations. Save argv[0] and\n-\t\t * restore it on error.\n-\t\t */\n+\tstrbuf_init(&cmd, 0);\n+\tstrbuf_addf(&cmd, \"git-%s\", argv[0]);\n \n-\t\ttmp = argv[0];\n-\t\targv[0] = git_command;\n+\t/* argv[0] must be the git command, but the argv array\n+\t * belongs to the caller, and my be reused in\n+\t * subsequent loop iterations. Save argv[0] and\n+\t * restore it on error.\n+\t */\n+\ttmp = argv[0];\n+\targv[0] = cmd.buf;\n \n-\t\ttrace_argv_printf(argv, -1, \"trace: exec:\");\n+\ttrace_argv_printf(argv, -1, \"trace: exec:\");\n \n-\t\t/* execve() can only ever return if it fails */\n-\t\texecve(git_command, (char **)argv, environ);\n+\t/* execvp() can only ever return if it fails */\n+\texecvp(cmd.buf, (char **)argv);\n \n-\t\ttrace_printf(\"trace: exec failed: %s\\n\", strerror(errno));\n+\ttrace_printf(\"trace: exec failed: %s\\n\", strerror(errno));\n \n-\t\targv[0] = tmp;\n-\t}\n-\treturn -1;\n+\targv[0] = tmp;\n \n+\tstrbuf_release(&cmd);\n+\n+\treturn -1;\n }\n \n \ndiff --git a/exec_cmd.h b/exec_cmd.h\nindex da99287..a892355 100644\n--- a/exec_cmd.h\n+++ b/exec_cmd.h\n@@ -3,6 +3,7 @@\n \n extern void git_set_argv_exec_path(const char *exec_path);\n extern const char* git_exec_path(void);\n+extern void setup_path(const char *);\n extern int execv_git_cmd(const char **argv); /* NULL terminated */\n extern int execl_git_cmd(const char *cmd, ...);\n \ndiff --git a/git.c b/git.c\nindex f659338..a639e42 100644\n--- a/git.c\n+++ b/git.c\n@@ -6,28 +6,6 @@\n const char git_usage_string[] =\n \t\"git [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate|--no-pager] [--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE] [--help] COMMAND [ARGS]\";\n \n-static void prepend_to_path(const char *dir, int len)\n-{\n-\tconst char *old_path = getenv(\"PATH\");\n-\tchar *path;\n-\tint path_len = len;\n-\n-\tif (!old_path)\n-\t\told_path = \"/usr/local/bin:/usr/bin:/bin\";\n-\n-\tpath_len = len + strlen(old_path) + 1;\n-\n-\tpath = xmalloc(path_len + 1);\n-\n-\tmemcpy(path, dir, len);\n-\tpath[len] = ':';\n-\tmemcpy(path + len + 1, old_path, path_len - len);\n-\n-\tsetenv(\"PATH\", path, 1);\n-\n-\tfree(path);\n-}\n-\n static int handle_options(const char*** argv, int* argc, int* envchanged)\n {\n \tint handled = 0;\n@@ -403,7 +381,7 @@ int main(int argc, const char **argv)\n {\n \tconst char *cmd = argv[0] ? argv[0] : \"git-help\";\n \tchar *slash = strrchr(cmd, '/');\n-\tconst char *exec_path = NULL;\n+\tconst char *cmd_path = NULL;\n \tint done_alias = 0;\n \n \t/*\n@@ -413,10 +391,7 @@ int main(int argc, const char **argv)\n \t */\n \tif (slash) {\n \t\t*slash++ = 0;\n-\t\tif (*cmd == '/')\n-\t\t\texec_path = cmd;\n-\t\telse\n-\t\t\texec_path = xstrdup(make_absolute_path(cmd));\n+\t\tcmd_path = cmd;\n \t\tcmd = slash;\n \t}\n \n@@ -451,16 +426,12 @@ int main(int argc, const char **argv)\n \tcmd = argv[0];\n \n \t/*\n-\t * We execute external git command via execv_git_cmd(),\n-\t * which looks at \"--exec-path\" option, GIT_EXEC_PATH\n-\t * environment, and $(gitexecdir) in Makefile while built,\n-\t * in this order.  For scripted commands, we prepend\n-\t * the value of the exec_path variable to the PATH.\n+\t * We use PATH to find git commands, but we prepend some higher\n+\t * precidence paths: the \"--exec-path\" option, the GIT_EXEC_PATH\n+\t * environment, and the $(gitexecdir) from the Makefile at build\n+\t * time.\n \t */\n-\tif (exec_path)\n-\t\tprepend_to_path(exec_path, strlen(exec_path));\n-\texec_path = git_exec_path();\n-\tprepend_to_path(exec_path, strlen(exec_path));\n+\tsetup_path(cmd_path);\n \n \twhile (1) {\n \t\t/* See if it's an internal command */\n-- \ngitgui.0.8.4.11176.gd9205-dirty\n"},{"id":"57026","messageId":"20071023211202.GA729@steel.home","threadId":"10431","inReplyTo":"20071023040844.GQ16291@srparish.net","subject":"Re: [PATCH trailing ws fixed] use only the PATH for exec'ing git commands","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-10-23T21:12:02Z","receivedAt":"2007-10-23T21:12:02Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Scott Parish, Tue, Oct 23, 2007 06:08:45 +0200:\n> We need to correctly set up PATH for non-c based git commands. Since we\n> already do this, we can just use that PATH and execvp, instead of looping\n> over the paths with execve.\n> \n> This patch adds a setup_path() function to exec_cmd.c, which sets\n> the PATH order correctly for our search order. execv_git_cmd() is\n> stripped down to setting up argv and calling execvp(). git.c's main()\n> only only needs to call setup_path().\n> \n> Signed-off-by: Scott R Parish <srp@srparish.net>\n\nAcked-by: Alex Riesen <raa.lkml@gmail.com>\n\nDon't forget to mention it needs the patch from Johannes re \"deducing\nexec_path from calls to git with a relative path\" and your\n\"current_exec_path\"-patch. Took me a while to figure these out...\n"},{"id":"57027","messageId":"1193174862.v1.fusewebmail-240137@f","threadId":"10431","inReplyTo":"20071023211202.GA729@steel.home","subject":"Re: [PATCH trailing ws fixed] use only the PATH for exec'ing gitcommands","fromName":"Scott R Parish","fromEmail":"srp@srparish.net","sentAt":"2007-10-23T21:27:42Z","receivedAt":"2007-10-23T21:27:42Z","isPatch":true,"sender":{"key":"srp@srparish.net","avatar":"https://gravatar.com/avatar/870e5b6fc4f710cf4db5684bd9af7f2cee5734b3dab3209b13e00cf64f6c9f0e?d=mp&s=160"},"body":"> Acked-by: Alex Riesen <raa.lkml@gmail.com>\n>\n> Don't forget to mention it needs the patch from Johannes re \"deducing\n> exec_path from calls to git with a relative path\" and your\n> \"current_exec_path\"-patch. Took me a while to figure these out...\n\nSorry about that! I was basing my patches off the head of spearce, as it\nsounded like Junio was going to pick that stuff up.\n\nsRp\n"}]}