aboutsummaryrefslogtreecommitdiff
path: root/path.c
diff options
context:
space:
mode:
authorRené Scharfe <rene.scharfe@lsrfire.ath.cx>2009-02-07 16:08:29 +0100
committerJunio C Hamano <gitster@pobox.com>2009-02-07 12:23:29 -0800
commit43a7ddb55d82d5c6f0c4d2cbe408a1df71d58ef3 (patch)
tree59fd700614e85f9f4f9054d946a92c4de5c89f0b /path.c
parentf3cad0ad82e24966bf7bcc8a47670c54c30e4b18 (diff)
downloadgit-43a7ddb55d82d5c6f0c4d2cbe408a1df71d58ef3.tar.gz
git-43a7ddb55d82d5c6f0c4d2cbe408a1df71d58ef3.tar.xz
Fix GIT_CEILING_DIRECTORIES on Windows
Using git with GIT_CEILING_DIRECTORIES crashed on Windows due to a failed assertion in normalize_absolute_path(): This function expects absolute paths to start with a slash, while on Windows they can start with a drive letter or a backslash. This fixes it by using the alternative, normalize_path_copy() instead, which can handle Windows-style paths just fine. Secondly, the portability macro PATH_SEP is used instead of expecting colons to be used as path list delimiter. The test script t1504 is also changed to help MSYS's bash recognize some program arguments as path list. (MSYS's bash must translate POSIX-style path lists to Windows-style path lists, and the heuristic did not catch some cases.) Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'path.c')
-rw-r--r--path.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/path.c b/path.c
index 820eab5ac..79c5c104c 100644
--- a/path.c
+++ b/path.c
@@ -524,15 +524,16 @@ int longest_ancestor_length(const char *path, const char *prefix_list)
return -1;
for (colon = ceil = prefix_list; *colon; ceil = colon+1) {
- for (colon = ceil; *colon && *colon != ':'; colon++);
+ for (colon = ceil; *colon && *colon != PATH_SEP; colon++);
len = colon - ceil;
if (len == 0 || len > PATH_MAX || !is_absolute_path(ceil))
continue;
strlcpy(buf, ceil, len+1);
- len = normalize_absolute_path(buf, buf);
- /* Strip "trailing slashes" from "/". */
- if (len == 1)
- len = 0;
+ if (normalize_path_copy(buf, buf) < 0)
+ continue;
+ len = strlen(buf);
+ if (len > 0 && buf[len-1] == '/')
+ buf[--len] = '\0';
if (!strncmp(path, buf, len) &&
path[len] == '/' &&