diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2020-03-08 16:34:23 +0000 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2020-03-08 18:23:29 +0000 |
commit | fb7da15452f7069e6bfa7d39b7703e32eaa84d34 (patch) | |
tree | f9e362f6360ae0232eb5ff0f9d1fed4d2249b993 | |
parent | e23b8b446522f17eb3329b62201aae7674f06e13 (diff) | |
download | libgit2-fb7da15452f7069e6bfa7d39b7703e32eaa84d34.tar.gz |
win32: clarify usage of path canonicalization funcs
The path canonicalization functions on win32 are intended to
canonicalize absolute paths; those with prefixes. In other words,
things start with drive letters (`C:\`), share names (`\\server\share`),
or other prefixes (`\\?\`).
This function removes leading `..` that occur after the prefix but
before the directory/file portion (eg, turning `C:\..\..\..\foo` into
`C:\foo`). This translation is not appropriate for local paths.
-rw-r--r-- | src/win32/path_w32.h | 3 | ||||
-rw-r--r-- | tests/path/win32.c | 10 |
2 files changed, 3 insertions, 10 deletions
diff --git a/src/win32/path_w32.h b/src/win32/path_w32.h index afd0aa155..6d546f2f8 100644 --- a/src/win32/path_w32.h +++ b/src/win32/path_w32.h @@ -26,6 +26,9 @@ extern int git_win32_path_from_utf8(git_win32_path dest, const char *src); * canonical (always backslashes, never forward slashes) and process any * directory entries of '.' or '..'. * + * Note that this is intended to be used on absolute Windows paths, those + * that start with `C:\`, `\\server\share`, `\\?\`, etc. + * * This processes the buffer in place. * * @param path The buffer to process diff --git a/tests/path/win32.c b/tests/path/win32.c index 3ed7d7a6a..347de8f43 100644 --- a/tests/path/win32.c +++ b/tests/path/win32.c @@ -203,16 +203,6 @@ void test_path_win32__canonicalize(void) test_canonicalize(L"C:/Foo/Bar", L"C:\\Foo\\Bar"); test_canonicalize(L"C:/", L"C:\\"); - test_canonicalize(L"Foo\\\\Bar\\\\Asdf\\\\", L"Foo\\Bar\\Asdf"); - test_canonicalize(L"Foo\\\\Bar\\\\..\\\\Asdf\\", L"Foo\\Asdf"); - test_canonicalize(L"Foo\\\\Bar\\\\.\\\\Asdf\\", L"Foo\\Bar\\Asdf"); - test_canonicalize(L"Foo\\\\..\\Bar\\\\.\\\\Asdf\\", L"Bar\\Asdf"); - test_canonicalize(L"\\", L""); - test_canonicalize(L"", L""); - test_canonicalize(L"Foo\\..\\..\\..\\..", L""); - test_canonicalize(L"..\\..\\..\\..", L""); - test_canonicalize(L"\\..\\..\\..\\..", L""); - test_canonicalize(L"\\\\?\\C:\\Foo\\Bar", L"\\\\?\\C:\\Foo\\Bar"); test_canonicalize(L"\\\\?\\C:\\Foo\\Bar\\", L"\\\\?\\C:\\Foo\\Bar"); test_canonicalize(L"\\\\?\\C:\\\\Foo\\.\\Bar\\\\..\\", L"\\\\?\\C:\\Foo"); |