Description
What version of Go are you using (go version
)?
$ go version go version go1.12.7 windows/amd64
Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (go env
)?
Applies to all OSes
What did you do?
- Mounted a UNC path as a drive letter.
- In CMD, switched the current working directory to that drive.
- Called filepath.Abs on a relative path.
- Called filepath.EvalSymlinks on the result of that function.
What did you expect to see?
The same results as calling GetFinalPathNameByHandle: a UNC path.
What did you see instead?
A path using the drive letter instead of the UNC path.
Notes
This affects any attempt to canonicalize paths using the output of Git in such a situation. Git produces some paths as absolute and some paths as relative, and uses GetFinalPathNameByHandle for canonicalizing absolute paths. However, Go lacks a function to canonicalize paths in a standard way, so it isn't possible to produce results equivalent to a C program and still write code that works portably across systems.
Go should add a function that is explicitly defined to canonicalize paths in a way equivalent to the underlying operating system, since using filepath.Abs and filepath.EvalSymlinks doesn't work correctly on Windows. It does work fine on Unix, but Unix paths are much simpler and easier to reason about.
It was determined in #17084 that filepath.Abs and filepath.EvalSymlinks were sufficient in this case, but that doesn't appear to be true. I expect there are other cases in which those don't work on Windows, but I am insufficiently versed in Windows paths to know what those are.
This was originally reported to the Git LFS project in git-lfs/git-lfs#4012.