diff --git a/Utility/Path.hs b/Utility/Path.hs index cfda748b9f..8c6aa7f704 100644 --- a/Utility/Path.hs +++ b/Utility/Path.hs @@ -187,7 +187,13 @@ relPathDirToFileAbs from to dotdots = replicate (length pfrom - numcommon) ".." numcommon = length common #ifdef mingw32_HOST_OS - normdrive = map toLower . takeWhile (/= ':') . fromRawFilePath . takeDrive + normdrive = map toLower + -- Get just the drive letter, removing any leading + -- path separator, which takeDrive leaves on the drive + -- letter. + . dropWhileEnd (isPathSeparator . fromIntegral . ord) + . fromRawFilePath + . takeDrive #endif {- Checks if a command is available in PATH. diff --git a/doc/bugs/test_prop__95__relPathDirToFileAbs__95__basics_fails_now__38__thn.mdwn b/doc/bugs/test_prop__95__relPathDirToFileAbs__95__basics_fails_now__38__thn.mdwn index 63151051cd..f65e66893a 100644 --- a/doc/bugs/test_prop__95__relPathDirToFileAbs__95__basics_fails_now__38__thn.mdwn +++ b/doc/bugs/test_prop__95__relPathDirToFileAbs__95__basics_fails_now__38__thn.mdwn @@ -49,3 +49,5 @@ Windows version 21H1 (build 19043.1165), 64 bit. Git Annex is great. It works with multi-gigabyte backup files (largest around 180GB) via the BLAKE2B160E backend just dandy :) [[!meta author=jkniiv]] + +> [[fixed|done]] --[[Joey]] diff --git a/doc/bugs/test_prop__95__relPathDirToFileAbs__95__basics_fails_now__38__thn/comment_1_7becd972ce41d14ace89a9bc1302abba._comment b/doc/bugs/test_prop__95__relPathDirToFileAbs__95__basics_fails_now__38__thn/comment_1_7becd972ce41d14ace89a9bc1302abba._comment new file mode 100644 index 0000000000..f5e468d6ec --- /dev/null +++ b/doc/bugs/test_prop__95__relPathDirToFileAbs__95__basics_fails_now__38__thn/comment_1_7becd972ce41d14ace89a9bc1302abba._comment @@ -0,0 +1,28 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 1""" + date="2021-09-01T14:54:56Z" + content=""" +Reproduced on Linux using System.FilePath.Windows. + +Minimal case is: + + ghci> let p = "\\\\\DLEJ\STXm{u5;4*\EOTKo1" + ghci> relPathDirToFileAbs (p "bar") p + "\\\\\DLEJ\STXm{u5;4*\EOTKo1" + +Which should be "bar", but the "normdrive" case in +relPathDirToFileAbs causes it to not return that. + +Ah, that whole value is treated as a "drive letter" due to starting +with "\\\\" and not containing any path separator. + + ghci> takeDrive p + "\\\\\DLEJ\STXm{u5;4*\EOTKo1" + +And takeDrive includes the first path separator, which is present in one +string and not in another. So, it thinks these paths are on +two different drives, when they are not. And that's the root +of the problem. normdrive was working around that by taking up until +the ':', but there *is* no ':' in this drive letter! +"""]]