diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-04-08 15:25:32 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-04-08 15:25:32 -0400 |
commit | 9e65dd757f9fe8e031ea936ce4e2a8cb998f7f83 (patch) | |
tree | 7b6e0c509838db15e079f57f176f5902e65508c5 | |
parent | fdfd56c647d685ad5618917341db0b7c97e1b63a (diff) |
hard links on windows
* annex.thin and annex.hardlink are now supported on Windows.
* unannex --fast now makes hard links on Windows.
-rw-r--r-- | Annex/Content.hs | 4 | ||||
-rw-r--r-- | Command/Unannex.hs | 6 | ||||
-rw-r--r-- | Remote/Git.hs | 4 | ||||
-rw-r--r-- | Utility/CopyFile.hs | 4 | ||||
-rw-r--r-- | Utility/PosixFiles.hs | 10 | ||||
-rw-r--r-- | debian/changelog | 2 | ||||
-rw-r--r-- | doc/design/adjusted_branches.mdwn | 23 | ||||
-rw-r--r-- | doc/tips/unlocked_files.mdwn | 2 |
8 files changed, 29 insertions, 26 deletions
diff --git a/Annex/Content.hs b/Annex/Content.hs index 9c4c1d5b8..a17098ad7 100644 --- a/Annex/Content.hs +++ b/Annex/Content.hs @@ -594,14 +594,10 @@ linkOrCopy' canhardlink key src dest = catchBoolIO $ where hardlink = do s <- getstat -#ifndef mingw32_HOST_OS if linkCount s > 1 then copy s else liftIO (createLink src dest >> return True) `catchIO` const (copy s) -#else - copy s -#endif copy = checkedCopyFile' key src dest getstat = liftIO $ getFileStatus src diff --git a/Command/Unannex.hs b/Command/Unannex.hs index f01d2b219..4e83fd420 100644 --- a/Command/Unannex.hs +++ b/Command/Unannex.hs @@ -5,8 +5,6 @@ - Licensed under the GNU GPL version 3 or higher. -} -{-# LANGUAGE CPP #-} - module Command.Unannex where import Command @@ -107,15 +105,11 @@ cleanupIndirect file key = do copyfrom src = thawContent file `after` liftIO (copyFileExternal CopyAllMetaData src file) hardlinkfrom src = -#ifndef mingw32_HOST_OS -- creating a hard link could fall; fall back to copying ifM (liftIO $ catchBoolIO $ createLink src file >> return True) ( return True , copyfrom src ) -#else - copyfrom src -#endif performDirect :: FilePath -> Key -> CommandPerform performDirect file key = do diff --git a/Remote/Git.hs b/Remote/Git.hs index 9f99dccab..256428137 100644 --- a/Remote/Git.hs +++ b/Remote/Git.hs @@ -695,7 +695,6 @@ mkCopier :: Bool -> [CommandParam] -> Annex Copier mkCopier remotewanthardlink rsyncparams = do let copier = \src dest p check -> unVerified $ rsyncOrCopyFile rsyncparams src dest p <&&> check -#ifndef mingw32_HOST_OS localwanthardlink <- wantHardLink let linker = \src dest -> createLink src dest >> return True ifM (pure (remotewanthardlink || localwanthardlink) <&&> not <$> isDirect) @@ -706,6 +705,3 @@ mkCopier remotewanthardlink rsyncparams = do ) , return copier ) -#else - return $ if remotewanthardlink then copier else copier -#endif diff --git a/Utility/CopyFile.hs b/Utility/CopyFile.hs index 46bc43d50..01c600504 100644 --- a/Utility/CopyFile.hs +++ b/Utility/CopyFile.hs @@ -49,13 +49,9 @@ copyFileExternal meta src dest = do {- Create a hard link if the filesystem allows it, and fall back to copying - the file. -} createLinkOrCopy :: FilePath -> FilePath -> IO Bool -#ifndef mingw32_HOST_OS createLinkOrCopy src dest = go `catchIO` const fallback where go = do createLink src dest return True fallback = copyFileExternal CopyAllMetaData src dest -#else -createLinkOrCopy = copyFileExternal CopyAllMetaData -#endif diff --git a/Utility/PosixFiles.hs b/Utility/PosixFiles.hs index 4550bebdf..37253da29 100644 --- a/Utility/PosixFiles.hs +++ b/Utility/PosixFiles.hs @@ -1,6 +1,6 @@ {- POSIX files (and compatablity wrappers). - - - This is like System.PosixCompat.Files, except with a fixed rename. + - This is like System.PosixCompat.Files, but with a few fixes. - - Copyright 2014 Joey Hess <id@joeyh.name> - @@ -21,6 +21,7 @@ import System.PosixCompat.Files as X hiding (rename) import System.Posix.Files (rename) #else import qualified System.Win32.File as Win32 +import qualified System.Win32.HardLink as Win32 #endif {- System.PosixCompat.Files.rename on Windows calls renameFile, @@ -32,3 +33,10 @@ import qualified System.Win32.File as Win32 rename :: FilePath -> FilePath -> IO () rename src dest = Win32.moveFileEx src dest Win32.mOVEFILE_REPLACE_EXISTING #endif + +{- System.PosixCompat.Files.createLink throws an error, but windows + - does support hard links. -} +#ifdef mingw32_HOST_OS +createLink :: FilePath -> FilePath -> IO () +createLink = Win32.createHardLink +#endif diff --git a/debian/changelog b/debian/changelog index 1134ca2de..bfde90da1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -14,6 +14,8 @@ git-annex (6.20160319) UNRELEASED; urgency=medium * log --raw-date: Use to display seconds from unix epoch. * v6: Close pointer file handles more quickly, to avoid problems on Windows. * sync: Show output of git commit. + * annex.thin and annex.hardlink are now supported on Windows. + * unannex --fast now makes hard links on Windows. -- Joey Hess <id@joeyh.name> Wed, 23 Mar 2016 11:42:36 -0400 diff --git a/doc/design/adjusted_branches.mdwn b/doc/design/adjusted_branches.mdwn index e94439d66..75ece6e99 100644 --- a/doc/design/adjusted_branches.mdwn +++ b/doc/design/adjusted_branches.mdwn @@ -280,9 +280,20 @@ into adjusted view worktrees.] to checkout the adjusted branch some other way. Maybe generalize so this more efficient checkout is available as a git-annex command? * There are potentially races in code that assumes a branch like - master is not being changed by someone else. In particular, - propigateAdjustedCommits rebases the adjusted branch on top of master. - That is called by sync. The assumption is that any changes in master - have already been handled by updateAdjustedBranch. But, if another remote - pushed a new master at just the right time, the adjusted branch could be - rebased on top of a master that it doesn't incorporate, which is wrong. + master is not being changed by someone else. + + In particular, propigateAdjustedCommits rebases the adjusted branch on + top of master. That is called by sync. The assumption is that any changes + in master have already been handled by updateAdjustedBranch. But, if + another remote pushed a new master at just the right time, the adjusted + branch could be rebased on top of a master that it doesn't incorporate, + which is wrong. + + Best fix seems to be to use a hidden ref, like refs/annex/adjusted/master + and copy master's ref to it when entering the view branch. Then, make + all adjustments via that ref, and propigate back to refs/heads/master. + + It's fine to overwrite changes that were pushed to master when + propigating from the adjusted branch. Synced changes also go to + synced/master so won't be lost. Pushes not made using git-annex sync + of master are not really desired, just a possibility. diff --git a/doc/tips/unlocked_files.mdwn b/doc/tips/unlocked_files.mdwn index cc9972f9e..20605b612 100644 --- a/doc/tips/unlocked_files.mdwn +++ b/doc/tips/unlocked_files.mdwn @@ -143,7 +143,7 @@ match the new setting: git annex fix Note that setting annex.thin only has any effect on systems that support -hard links. Ie, not Windows, and not FAT filesystems. +hard links. It is supported on Windows, but not on FAT filesystems. ## tradeoffs |