diff options
author | 2016-04-14 14:30:15 -0400 | |
---|---|---|
committer | 2016-04-14 14:47:08 -0400 | |
commit | 8f2cde77f63fe873341554192b1c7df71cc8bdc1 (patch) | |
tree | c3858d3491fce3732db2e6abacb91df1dd552b0e /Annex/Ingest.hs | |
parent | 1835f915174e9fdf5aa73372efa80e4330b528f2 (diff) |
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.
Diffstat (limited to 'Annex/Ingest.hs')
-rw-r--r-- | Annex/Ingest.hs | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/Annex/Ingest.hs b/Annex/Ingest.hs index 1bf1db146..95bbff496 100644 --- a/Annex/Ingest.hs +++ b/Annex/Ingest.hs @@ -130,7 +130,9 @@ ingestAdd ld@(Just (LockedDown cfg source)) = do ( do l <- calcRepo $ gitAnnexLink f k stageSymlink f =<< hashSymlink l - , stagePointerFile f =<< hashPointerFile k + , do + mode <- liftIO $ catchMaybeIO $ fileMode <$> getFileStatus (contentLocation source) + stagePointerFile f mode =<< hashPointerFile k ) return (Just k) @@ -344,15 +346,19 @@ cachedCurrentBranch = maybe cache (return . Just) addAnnexedFile :: FilePath -> Key -> Maybe FilePath -> Annex () addAnnexedFile file key mtmp = ifM (addUnlocked <&&> not <$> isDirect) ( do - stagePointerFile file =<< hashPointerFile key + mode <- maybe + (pure Nothing) + (\tmp -> liftIO $ catchMaybeIO $ fileMode <$> getFileStatus tmp) + mtmp + stagePointerFile file mode =<< hashPointerFile key Database.Keys.addAssociatedFile key =<< inRepo (toTopFilePath file) case mtmp of Just tmp -> do moveAnnex key tmp - linkunlocked + linkunlocked mode Nothing -> ifM (inAnnex key) - ( linkunlocked - , writepointer + ( linkunlocked mode + , liftIO $ writePointerFile file key mode ) , do addLink file key Nothing @@ -368,9 +374,9 @@ addAnnexedFile file key mtmp = ifM (addUnlocked <&&> not <$> isDirect) Nothing -> return () ) where - writepointer = liftIO $ writeFile file (formatPointer key) - linkunlocked = do - r <- linkFromAnnex key file + linkunlocked mode = do + r <- linkFromAnnex key file mode case r of - LinkAnnexFailed -> writepointer + LinkAnnexFailed -> liftIO $ + writePointerFile file key mode _ -> return () |