summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4fcc86b)
raw | patch | inline | side by side (parent: 4fcc86b)
author | Johannes Schindelin <johannes.schindelin@gmx.de> | |
Thu, 19 Feb 2009 19:10:53 +0000 (20:10 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 20 Feb 2009 06:47:39 +0000 (22:47 -0800) |
At least for the author of this patch, the logic in system_path() was
too hard to understand. Using the function strip_path_suffix() documents
the idea of the code better.
The real change is to add the suffix "git", so that a runtime prefix will
be computed correctly even when the executable was called in /git/ as is
the case in msysGit (Windows insists to search the current directory
before the PATH when looking for an executable).
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Acked-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
too hard to understand. Using the function strip_path_suffix() documents
the idea of the code better.
The real change is to add the suffix "git", so that a runtime prefix will
be computed correctly even when the executable was called in /git/ as is
the case in msysGit (Windows insists to search the current directory
before the PATH when looking for an executable).
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Acked-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
exec_cmd.c | patch | blob | history |
diff --git a/exec_cmd.c b/exec_cmd.c
index f234066defd637dc3c048ba3d9eb43f1ecbad446..217c12577f52b8ff9d535a086ec75d54107ee01c 100644 (file)
--- a/exec_cmd.c
+++ b/exec_cmd.c
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. "