Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/path.c
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2022-03-17 12:57:50 +0300
committerJohannes Schindelin <johannes.schindelin@gmx.de>2022-03-24 02:31:36 +0300
commit93fbff09eb8ed9e728a61623a15a53a46a762639 (patch)
tree708e878ae901e2fb073a1ca546768442c76ee20b /path.c
parente9d7761bb94f20acc98824275e317fa82436c25d (diff)
parent87ed4fc046840706138d46e0033a009e74c3887a (diff)
Sync with 2.33.2
* maint-2.33: Git 2.33.2 Git 2.32.1 Git 2.31.2 GIT-VERSION-GEN: bump to v2.33.1 Git 2.30.3 setup_git_directory(): add an owner check for the top-level directory Add a function to determine whether a path is owned by the current user
Diffstat (limited to 'path.c')
-rw-r--r--path.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/path.c b/path.c
index 2c895471d9..d73146b6cd 100644
--- a/path.c
+++ b/path.c
@@ -1225,11 +1225,15 @@ int longest_ancestor_length(const char *path, struct string_list *prefixes)
const char *ceil = prefixes->items[i].string;
int len = strlen(ceil);
- if (len == 1 && ceil[0] == '/')
- len = 0; /* root matches anything, with length 0 */
- else if (!strncmp(path, ceil, len) && path[len] == '/')
- ; /* match of length len */
- else
+ /*
+ * For root directories (`/`, `C:/`, `//server/share/`)
+ * adjust the length to exclude the trailing slash.
+ */
+ if (len > 0 && ceil[len - 1] == '/')
+ len--;
+
+ if (strncmp(path, ceil, len) ||
+ path[len] != '/' || !path[len + 1])
continue; /* no match */
if (len > max_len)