aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--path.c11
-rwxr-xr-xt/t1504-ceiling-dirs.sh6
2 files changed, 9 insertions, 8 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] == '/' &&
diff --git a/t/t1504-ceiling-dirs.sh b/t/t1504-ceiling-dirs.sh
index 91b704a3a..e377d4890 100755
--- a/t/t1504-ceiling-dirs.sh
+++ b/t/t1504-ceiling-dirs.sh
@@ -93,13 +93,13 @@ GIT_CEILING_DIRECTORIES="$TRASH_ROOT/subdi"
test_prefix subdir_ceil_at_subdi_slash "sub/dir/"
-GIT_CEILING_DIRECTORIES="foo:$TRASH_ROOT/sub"
+GIT_CEILING_DIRECTORIES="/foo:$TRASH_ROOT/sub"
test_fail second_of_two
-GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub:bar"
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub:/bar"
test_fail first_of_two
-GIT_CEILING_DIRECTORIES="foo:$TRASH_ROOT/sub:bar"
+GIT_CEILING_DIRECTORIES="/foo:$TRASH_ROOT/sub:/bar"
test_fail second_of_three