summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-02-08 15:31:03 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-02-08 15:39:04 -0400
commitb1915b9054ffa57e84c1300ac0d0d9bc1c7af20d (patch)
treec4b7771e493a5c8997e04dcf93868e6d5b94fe89
parent97f152eff1d9b1c7543844dacda8c264aadede9f (diff)
Windows: Fix handling of absolute unix-style git repository paths.
Note that on Windows a remote with a path like /home/foo/bar is interpreted by git as being some screwy relative path (relative to what exactly seems ill-defined -- it seemed relative to C:\Program Files\Git\ in my tests!) So no attempt has been made to handle such a path sanely, just not to crash when encountering it. Note that "C:\\foo" </> "/home/foo/bar" yields /home/foo/bar even though that is not absolute! I don't know what to make of all this, except that I will be very happy when this crock of **** vanishes from the face of the earth.
-rw-r--r--CmdLine/GitAnnexShell/Fields.hs3
-rw-r--r--Git/Command.hs2
-rw-r--r--Git/Construct.hs3
-rw-r--r--Git/FilePath.hs12
-rw-r--r--debian/changelog2
-rw-r--r--doc/bugs/assistant_on_windows_adding_remote_containing_linux_paths.mdwn11
6 files changed, 28 insertions, 5 deletions
diff --git a/CmdLine/GitAnnexShell/Fields.hs b/CmdLine/GitAnnexShell/Fields.hs
index e71f2c2a0..4f208773b 100644
--- a/CmdLine/GitAnnexShell/Fields.hs
+++ b/CmdLine/GitAnnexShell/Fields.hs
@@ -9,6 +9,7 @@ module CmdLine.GitAnnexShell.Fields where
import Common.Annex
import qualified Annex
+import Git.FilePath
import Data.Char
@@ -29,7 +30,7 @@ remoteUUID = Field "remoteuuid" $
associatedFile :: Field
associatedFile = Field "associatedfile" $ \f ->
-- is the file a safe relative filename?
- not (isAbsolute f) && not ("../" `isPrefixOf` f)
+ not (absoluteGitPath f) && not ("../" `isPrefixOf` f)
direct :: Field
direct = Field "direct" $ \f -> f == "1"
diff --git a/Git/Command.hs b/Git/Command.hs
index 90abc7e4f..034c4ecb5 100644
--- a/Git/Command.hs
+++ b/Git/Command.hs
@@ -32,7 +32,7 @@ gitCommandLine params r@(Repo { location = l@(Local _ _ ) }) =
#ifdef mingw32_HOST_OS
-- despite running on windows, msysgit wants a unix-formatted path
gitpath s
- | isAbsolute s = "/" ++ dropDrive (toInternalGitPath s)
+ | absoluteGitPath s = "/" ++ dropDrive (toInternalGitPath s)
| otherwise = s
#else
gitpath = id
diff --git a/Git/Construct.hs b/Git/Construct.hs
index 71a13f49f..eed2b9930 100644
--- a/Git/Construct.hs
+++ b/Git/Construct.hs
@@ -33,6 +33,7 @@ import Common
import Git.Types
import Git
import Git.Remote
+import Git.FilePath
import qualified Git.Url as Url
import Utility.UserInfo
@@ -57,7 +58,7 @@ fromPath dir = fromAbsPath =<< absPath dir
- specified. -}
fromAbsPath :: FilePath -> IO Repo
fromAbsPath dir
- | isAbsolute dir = ifM (doesDirectoryExist dir') ( ret dir' , hunt )
+ | absoluteGitPath dir = ifM (doesDirectoryExist dir') ( ret dir' , hunt )
| otherwise =
error $ "internal error, " ++ dir ++ " is not absolute"
where
diff --git a/Git/FilePath.hs b/Git/FilePath.hs
index a128277dc..42eb0812e 100644
--- a/Git/FilePath.hs
+++ b/Git/FilePath.hs
@@ -20,12 +20,15 @@ module Git.FilePath (
asTopFilePath,
InternalGitPath,
toInternalGitPath,
- fromInternalGitPath
+ fromInternalGitPath,
+ absoluteGitPath
) where
import Common
import Git
+import qualified System.FilePath.Posix
+
{- A FilePath, relative to the top of the git repository. -}
newtype TopFilePath = TopFilePath { getTopFilePath :: FilePath }
deriving (Show)
@@ -66,3 +69,10 @@ fromInternalGitPath = id
#else
fromInternalGitPath = replace "/" "\\"
#endif
+
+{- isAbsolute on Windows does not think "/foo" or "\foo" is absolute,
+ - so try posix paths.
+ -}
+absoluteGitPath :: FilePath -> Bool
+absoluteGitPath p = isAbsolute p ||
+ System.FilePath.Posix.isAbsolute (toInternalGitPath p)
diff --git a/debian/changelog b/debian/changelog
index 57f69b34c..3a63d0432 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -29,12 +29,14 @@ git-annex (5.20140128) UNRELEASED; urgency=medium
* Windows: Fix deletion of repositories by test suite and webapp.
* Windows: Test suite 100% passes again.
* Windows: Fix bug in symlink calculation code.
+ * Windows: Fix handling of absolute unix-style git repository paths.
* Fix initremote with encryption=pubkey to work with S3, glacier, webdav,
and external special remotes.
* Android: Avoid crashing when unable to set file mode for ssh config file
due to Android filesystem horribleness.
* Avoid building with DAV 0.6 which is badly broken (see #737902).
* Fix build on platforms not supporting the webapp.
+ * Fix dropping of unused keys with spaces in their name.
-- Joey Hess <joeyh@debian.org> Tue, 28 Jan 2014 13:57:19 -0400
diff --git a/doc/bugs/assistant_on_windows_adding_remote_containing_linux_paths.mdwn b/doc/bugs/assistant_on_windows_adding_remote_containing_linux_paths.mdwn
index cdaabf78e..c6b6ee482 100644
--- a/doc/bugs/assistant_on_windows_adding_remote_containing_linux_paths.mdwn
+++ b/doc/bugs/assistant_on_windows_adding_remote_containing_linux_paths.mdwn
@@ -6,9 +6,18 @@ internal error, /home/michele/assistannex is not absolute
### What steps will reproduce the problem?
-create a transfer repository on a usb drive (from windows) merge it with a repository on linux, try to merge it on another target windows machine
+create a transfer repository on a usb drive (from windows) merge it with a
+repository on linux, try to merge it on another target windows machine
### What version of git-annex are you using? On what operating system?
git-annex version 5.20140128-g29aea74
+> I'm not able to follow the steps to reproduce this, but I think
+> I see what the problem is. `isAbsolute` on windows does not think that
+> unix-style path is absolute. Such a path can appear in a remote of a git
+> repository, particularly if part of that repository was set up on a
+> non-Windows system. While the remote won't be usable on Windows with a
+> path like that, git-annex should not choke on the path either.
+> I have fixed the code to deal with this.
+> [[done]] --[[Joey]]