Preserve execute bits of unlocked files in v6 mode.

When annex.thin is set, adding an object will add the execute bits to the
work tree file, and this does mean that the annex object file ends up
executable.

This doesn't add any complexity that wasn't already present, because git
annex add of an executable file has always ingested it so that the annex
object ends up executable.

But, since an annex object file can be executable or not, when populating
an unlocked file from one, the executable bit is always added or removed
to match the mode of the pointer file.
This commit is contained in:
Joey Hess 2016-04-14 14:30:15 -04:00
parent d05a75e45a
commit b7c8bf5274
Failed to extract signature
12 changed files with 128 additions and 67 deletions

View file

@ -15,6 +15,7 @@ import Annex.Version
import Annex.Link
import Annex.ReplaceFile
import Utility.CopyFile
import Utility.FileMode
cmd :: Command
cmd = mkcmd "unlock" "unlock files for modification"
@ -50,16 +51,17 @@ start file key = ifM (isJust <$> isAnnexLink file)
performNew :: FilePath -> Key -> CommandPerform
performNew dest key = do
destmode <- liftIO $ catchMaybeIO $ fileMode <$> getFileStatus dest
replaceFile dest $ \tmp -> do
r <- linkFromAnnex key tmp
r <- linkFromAnnex key tmp destmode
case r of
LinkAnnexOk -> return ()
_ -> error "unlock failed"
next $ cleanupNew dest key
next $ cleanupNew dest key destmode
cleanupNew :: FilePath -> Key -> CommandCleanup
cleanupNew dest key = do
stagePointerFile dest =<< hashPointerFile key
cleanupNew :: FilePath -> Key -> Maybe FileMode -> CommandCleanup
cleanupNew dest key destmode = do
stagePointerFile dest destmode =<< hashPointerFile key
return True
startOld :: FilePath -> Key -> CommandStart