mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-29 19:04:05 +00:00
Merge pull request #600 from nulltoken/fix/windows-network-paths
Fix windows network paths
This commit is contained in:
commit
4cfe2ab60b
@ -171,6 +171,15 @@ int git_path_root(const char *path)
|
|||||||
/* Does the root of the path look like a windows drive ? */
|
/* Does the root of the path look like a windows drive ? */
|
||||||
if (isalpha(path[0]) && (path[1] == ':'))
|
if (isalpha(path[0]) && (path[1] == ':'))
|
||||||
offset += 2;
|
offset += 2;
|
||||||
|
|
||||||
|
/* Are we dealing with a network path? */
|
||||||
|
else if (path[0] == '/' && path[1] == '/') {
|
||||||
|
offset += 2;
|
||||||
|
|
||||||
|
/* Skip the computer name segment */
|
||||||
|
while (*(path + offset) && *(path + offset) != '/')
|
||||||
|
offset++;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (*(path + offset) == '/')
|
if (*(path + offset) == '/')
|
||||||
|
@ -388,3 +388,18 @@ void test_core_path__11_walkup(void)
|
|||||||
|
|
||||||
git_buf_free(&p);
|
git_buf_free(&p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_core_path__12_offset_to_path_root(void)
|
||||||
|
{
|
||||||
|
cl_assert(git_path_root("non/rooted/path") == -1);
|
||||||
|
cl_assert(git_path_root("/rooted/path") == 0);
|
||||||
|
|
||||||
|
#ifdef GIT_WIN32
|
||||||
|
/* Windows specific tests */
|
||||||
|
cl_assert(git_path_root("C:non/rooted/path") == -1);
|
||||||
|
cl_assert(git_path_root("C:/rooted/path") == 2);
|
||||||
|
cl_assert(git_path_root("//computername/sharefolder/resource") == 14);
|
||||||
|
cl_assert(git_path_root("//computername/sharefolder") == 14);
|
||||||
|
cl_assert(git_path_root("//computername") == -1);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user