Fix issue #4821 with path canonicalization for Win32 paths#4825
Conversation
pks-t
left a comment
There was a problem hiding this comment.
Thanks for your changes! I cannot really argue whether the change is correct or not, I defer that to @ethomson, as he's more familiar with Windows systems. I have some proposals though for improving the added tests.
Anyway, thanks for working on this!
|
/rebuild |
|
Okay, @ethomson, I started to rebuild this pull request. |
| #endif | ||
| } | ||
|
|
||
| void static test_canonicalize_path(const wchar_t *in, const wchar_t *expected) |
There was a problem hiding this comment.
These here are switched ;)
| void static test_canonicalize_path(const wchar_t *in, const wchar_t *expected) | |
| static void test_canonicalize_path(const wchar_t *in, const wchar_t *expected) |
| } | ||
|
|
||
| void test_canonicalize(const wchar_t *in, const wchar_t *expected) | ||
| void static test_canonicalize(const wchar_t *in, const wchar_t *expected) |
There was a problem hiding this comment.
Same over here:
| void static test_canonicalize(const wchar_t *in, const wchar_t *expected) | |
| static void test_canonicalize(const wchar_t *in, const wchar_t *expected) |
|
Oh, just saw that Ed took this over. So you probably don't have to do anything, he's fixed your commits and they'll be merged as part of #4852 :) |
|
Thanks again @GabeDeBacker for the fix and especially for the tests! 😀 Hope you don't mind that I wanted to fix up some other issues in our code base that I noticed while reviewing this. (They were obviously our problems, not problems in this PR, but they confused me during the review so I wanted to get them cleaned up.) Thanks again! |
This pull request fixes issue #4821.
This issue occurs when a user has a reparse point (symbol link) for their global %userprofile%.gitconfig file the points to a Windows UNC share.
The p_stat function correctly determines that the path is a symbolic link and uses the getfinalpath_w function to Windows file path that can be used with GetFileAttributesEx. The getfinalypath_w ultimately uses git_win32__canonicalize_path to strip any prefixes that may have been returned by GetFinalPathNameByHandleW (for example "\\?\.\UNC\). However, when a UNC path is converted, the beginning "\\" characters where incorrectly stripped from the path, leaving an incorrect file name.
This libgit to be unable to locate and read the .gitconfig file.