@@ -53,7 +53,23 @@ function pathsAreEqual (pathA, pathB, caseInsensitive = false) {
5353 pathB = pathB . toLowerCase ( ) ;
5454 }
5555
56- return pathA === pathB ;
56+ let result = pathA === pathB ;
57+ if ( result || ! IS_WINDOWS ) return result ;
58+ if ( ! pathA . includes ( '~' ) && ! pathB . includes ( '~' ) ) {
59+ return result ;
60+ }
61+
62+ // If we get this far, we're on Windows and comparing two paths, at least one
63+ // of which contains an 8.3 short name. The only obvious and reliable way to
64+ // address this is to `statSync` both paths and verify their IDs are the
65+ // same.
66+ if ( ! fs . existsSync ( pathA ) || ! fs . existsSync ( pathB ) ) {
67+ return result ;
68+ }
69+ let statA = fs . statSync ( pathA ) ;
70+ let statB = fs . statSync ( pathB ) ;
71+
72+ return statA . ino === statB . ino && statA . dev === statB . dev ;
5773}
5874
5975Repository . prototype . release = function ( ) {
@@ -259,7 +275,8 @@ Repository.prototype.isWorkingDirectory = function (dirPath) {
259275 }
260276 dirPath = normalizePath ( realpath ( dirPath ) )
261277 console . log ( 'normalized dirPath to' , dirPath )
262- if ( ! fs . existsSync ( dirPath ) ) return false
278+ if ( ! fs . existsSync ( dirPath ) ) {
279+ return false
263280 } else {
264281 dirPath = normalizePath ( dirPath )
265282 }
@@ -361,6 +378,7 @@ function promisify (fn) {
361378}
362379
363380function realpath ( unrealPath ) {
381+ console . log ( 'realpath for:' , unrealPath ) ;
364382 try {
365383 return fs . realpathSync ( unrealPath )
366384 } catch ( e ) {
0 commit comments