Commit cae52938 by Russell Belfer

Fix resolving relative windows network paths

parent 0d1af399
......@@ -242,8 +242,8 @@ int git_path_root(const char *path)
#ifdef GIT_WIN32
/* Are we dealing with a windows network path? */
else if ((path[0] == '/' && path[1] == '/') ||
(path[0] == '\\' && path[1] == '\\'))
else if ((path[0] == '/' && path[1] == '/' && path[2] != '/') ||
(path[0] == '\\' && path[1] == '\\' && path[2] != '\\'))
{
offset += 2;
......
......@@ -538,7 +538,6 @@ void test_core_path__15_resolve_relative(void)
assert_resolve_relative(&buf, "a/b/", "a/b/.");
assert_resolve_relative(&buf, "/a/b/c", "///a/b/c");
assert_resolve_relative(&buf, "/a/b/c", "//a/b/c");
assert_resolve_relative(&buf, "/", "////");
assert_resolve_relative(&buf, "/a", "///a");
assert_resolve_relative(&buf, "/", "///.");
......@@ -565,5 +564,20 @@ void test_core_path__15_resolve_relative(void)
cl_git_pass(git_buf_sets(&buf, "////.."));
cl_git_fail(git_path_resolve_relative(&buf, 0));
/* things that start with Windows network paths */
#ifdef GIT_WIN32
assert_resolve_relative(&buf, "//a/b/c", "//a/b/c");
assert_resolve_relative(&buf, "//a/", "//a/b/..");
assert_resolve_relative(&buf, "//a/b/c", "//a/Q/../b/x/y/../../c");
cl_git_pass(git_buf_sets(&buf, "//a/b/../.."));
cl_git_fail(git_path_resolve_relative(&buf, 0));
#else
assert_resolve_relative(&buf, "/a/b/c", "//a/b/c");
assert_resolve_relative(&buf, "/a/", "//a/b/..");
assert_resolve_relative(&buf, "/a/b/c", "//a/Q/../b/x/y/../../c");
assert_resolve_relative(&buf, "/", "//a/b/../..");
#endif
git_buf_free(&buf);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment