Skip to content

Commit fb7da15

Browse files
committed
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.
1 parent e23b8b4 commit fb7da15

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

src/win32/path_w32.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ extern int git_win32_path_from_utf8(git_win32_path dest, const char *src);
2626
* canonical (always backslashes, never forward slashes) and process any
2727
* directory entries of '.' or '..'.
2828
*
29+
* Note that this is intended to be used on absolute Windows paths, those
30+
* that start with `C:\`, `\\server\share`, `\\?\`, etc.
31+
*
2932
* This processes the buffer in place.
3033
*
3134
* @param path The buffer to process

tests/path/win32.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -203,16 +203,6 @@ void test_path_win32__canonicalize(void)
203203
test_canonicalize(L"C:/Foo/Bar", L"C:\\Foo\\Bar");
204204
test_canonicalize(L"C:/", L"C:\\");
205205

206-
test_canonicalize(L"Foo\\\\Bar\\\\Asdf\\\\", L"Foo\\Bar\\Asdf");
207-
test_canonicalize(L"Foo\\\\Bar\\\\..\\\\Asdf\\", L"Foo\\Asdf");
208-
test_canonicalize(L"Foo\\\\Bar\\\\.\\\\Asdf\\", L"Foo\\Bar\\Asdf");
209-
test_canonicalize(L"Foo\\\\..\\Bar\\\\.\\\\Asdf\\", L"Bar\\Asdf");
210-
test_canonicalize(L"\\", L"");
211-
test_canonicalize(L"", L"");
212-
test_canonicalize(L"Foo\\..\\..\\..\\..", L"");
213-
test_canonicalize(L"..\\..\\..\\..", L"");
214-
test_canonicalize(L"\\..\\..\\..\\..", L"");
215-
216206
test_canonicalize(L"\\\\?\\C:\\Foo\\Bar", L"\\\\?\\C:\\Foo\\Bar");
217207
test_canonicalize(L"\\\\?\\C:\\Foo\\Bar\\", L"\\\\?\\C:\\Foo\\Bar");
218208
test_canonicalize(L"\\\\?\\C:\\\\Foo\\.\\Bar\\\\..\\", L"\\\\?\\C:\\Foo");

0 commit comments

Comments
 (0)