diff options
author | Johannes Schindelin <johannes.schindelin@gmx.de> | 2022-03-17 10:57:37 +0100 |
---|---|---|
committer | Johannes Schindelin <johannes.schindelin@gmx.de> | 2022-03-24 00:31:28 +0100 |
commit | 201b0c7af6cad52cf6f0cfc46bd48201a23f6224 (patch) | |
tree | 547fbd4dbd137b196be7ae2a1be1352ea6c1ed6d /path.c | |
parent | Git 2.32 (diff) | |
parent | Git 2.31.2 (diff) | |
download | git-201b0c7af6cad52cf6f0cfc46bd48201a23f6224.tar.xz git-201b0c7af6cad52cf6f0cfc46bd48201a23f6224.zip |
Sync with 2.31.2
* maint-2.31:
Git 2.31.2
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.c | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -1218,11 +1218,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) |