X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=exec_cmd.c;h=408e4e55e1c58931444c772d35d23b505bf3e2ea;hb=60ecac98ed6f420c6bf823491074219087c749d4;hp=f234066defd637dc3c048ba3d9eb43f1ecbad446;hpb=ba743d1b0ce0b44c797c0de06c9db2781e4d1fdd;p=git.git diff --git a/exec_cmd.c b/exec_cmd.c index f234066de..408e4e55e 100644 --- a/exec_cmd.c +++ b/exec_cmd.c @@ -23,35 +23,10 @@ const char *system_path(const char *path) assert(argv0_path); assert(is_absolute_path(argv0_path)); - if (!prefix) { - const char *strip[] = { - GIT_EXEC_PATH, - BINDIR, - 0 - }; - const char **s; - - for (s = strip; *s; s++) { - const char *sargv = argv0_path + strlen(argv0_path); - const char *ss = *s + strlen(*s); - while (argv0_path < sargv && *s < ss - && (*sargv == *ss || - (is_dir_sep(*sargv) && is_dir_sep(*ss)))) { - sargv--; - ss--; - } - if (*s == ss) { - struct strbuf d = STRBUF_INIT; - /* We also skip the trailing directory separator. */ - assert(sargv - argv0_path - 1 >= 0); - strbuf_add(&d, argv0_path, sargv - argv0_path - 1); - prefix = strbuf_detach(&d, NULL); - break; - } - } - } - - if (!prefix) { + if (!prefix && + !(prefix = strip_path_suffix(argv0_path, GIT_EXEC_PATH)) && + !(prefix = strip_path_suffix(argv0_path, BINDIR)) && + !(prefix = strip_path_suffix(argv0_path, "git"))) { prefix = PREFIX; fprintf(stderr, "RUNTIME_PREFIX requested, " "but prefix computation failed. " @@ -86,6 +61,10 @@ const char *git_extract_argv0_path(const char *argv0) void git_set_argv_exec_path(const char *exec_path) { argv_exec_path = exec_path; + /* + * Propagate this setting to external programs. + */ + setenv(EXEC_PATH_ENVIRONMENT, exec_path, 1); }