Do not preserve permissions and acls when copying files from one local git repository to another. Timestamps are still preserved as long as cp --preserve=timestamps is supported.
This avoids cp -a overriding the default mode acls that the user might have set in a git repository. With GNU cp, this behavior change should not be a breaking change, because git-anex also uses rsync sometimes in the same situation, and has only ever preserved timestamps when using rsync. Systems without GNU cp will no longer use cp -a, but instead just cp. So, timestamps will no longer be preserved. Preserving timestamps when copying between repos is not guaranteed anyway. Closes: #729757
This commit is contained in:
parent
06b51f67ac
commit
6eb5c3f479
11 changed files with 28 additions and 16 deletions
|
@ -1,6 +1,6 @@
|
|||
{- file copying
|
||||
-
|
||||
- Copyright 2010-2013 Joey Hess <joey@kitenet.net>
|
||||
- Copyright 2010-2014 Joey Hess <joey@kitenet.net>
|
||||
-
|
||||
- License: BSD-2-clause
|
||||
-}
|
||||
|
@ -9,16 +9,20 @@
|
|||
|
||||
module Utility.CopyFile (
|
||||
copyFileExternal,
|
||||
createLinkOrCopy
|
||||
createLinkOrCopy,
|
||||
CopyMetaData(..)
|
||||
) where
|
||||
|
||||
import Common
|
||||
import qualified Build.SysConfig as SysConfig
|
||||
|
||||
data CopyMetaData = CopyTimeStamps | CopyAllMetaData
|
||||
deriving (Eq)
|
||||
|
||||
{- The cp command is used, because I hate reinventing the wheel,
|
||||
- and because this allows easy access to features like cp --reflink. -}
|
||||
copyFileExternal :: FilePath -> FilePath -> IO Bool
|
||||
copyFileExternal src dest = do
|
||||
copyFileExternal :: CopyMetaData -> FilePath -> FilePath -> IO Bool
|
||||
copyFileExternal meta src dest = do
|
||||
whenM (doesFileExist dest) $
|
||||
removeFile dest
|
||||
boolSystem "cp" $ params ++ [File src, File dest]
|
||||
|
@ -26,12 +30,16 @@ copyFileExternal src dest = do
|
|||
#ifndef __ANDROID__
|
||||
params = map snd $ filter fst
|
||||
[ (SysConfig.cp_reflink_auto, Param "--reflink=auto")
|
||||
, (SysConfig.cp_a, Param "-a")
|
||||
, (SysConfig.cp_p && not SysConfig.cp_a, Param "-p")
|
||||
, (allmeta && SysConfig.cp_a, Param "-a")
|
||||
, (allmeta && SysConfig.cp_p && not SysConfig.cp_a
|
||||
, Param "-p")
|
||||
, (not allmeta && SysConfig.cp_preserve_timestamps
|
||||
, Param "--preserve=timestamps")
|
||||
]
|
||||
#else
|
||||
params = []
|
||||
#endif
|
||||
allmeta = meta == CopyAllMetaData
|
||||
|
||||
{- Create a hard link if the filesystem allows it, and fall back to copying
|
||||
- the file. -}
|
||||
|
@ -42,7 +50,7 @@ createLinkOrCopy src dest = go `catchIO` const fallback
|
|||
go = do
|
||||
createLink src dest
|
||||
return True
|
||||
fallback = copyFileExternal src dest
|
||||
fallback = copyFileExternal CopyAllMetaData src dest
|
||||
#else
|
||||
createLinkOrCopy = copyFileExternal
|
||||
createLinkOrCopy = copyFileExternal CopyAllMetaData
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue