summaryrefslogtreecommitdiff
path: root/Annex/Link.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-04-14 14:30:15 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-04-14 14:47:08 -0400
commit8f2cde77f63fe873341554192b1c7df71cc8bdc1 (patch)
treec3858d3491fce3732db2e6abacb91df1dd552b0e /Annex/Link.hs
parent1835f915174e9fdf5aa73372efa80e4330b528f2 (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/Link.hs')
-rw-r--r--Annex/Link.hs16
1 files changed, 13 insertions, 3 deletions
diff --git a/Annex/Link.hs b/Annex/Link.hs
index 44c567837..af20ae30d 100644
--- a/Annex/Link.hs
+++ b/Annex/Link.hs
@@ -23,6 +23,7 @@ import qualified Annex.Queue
import Git.Types
import Git.FilePath
import Annex.HashObject
+import Utility.FileMode
import qualified Data.ByteString.Lazy as L
import Data.Int
@@ -118,10 +119,19 @@ hashPointerFile :: Key -> Annex Sha
hashPointerFile key = hashBlob (formatPointer key)
{- Stages a pointer file, using a Sha of its content -}
-stagePointerFile :: FilePath -> Sha -> Annex ()
-stagePointerFile file sha =
+stagePointerFile :: FilePath -> Maybe FileMode -> Sha -> Annex ()
+stagePointerFile file mode sha =
Annex.Queue.addUpdateIndex =<<
- inRepo (Git.UpdateIndex.stageFile sha FileBlob file)
+ inRepo (Git.UpdateIndex.stageFile sha blobtype file)
+ where
+ blobtype
+ | maybe False isExecutable mode = ExecutableBlob
+ | otherwise = FileBlob
+
+writePointerFile :: FilePath -> Key -> Maybe FileMode -> IO ()
+writePointerFile file k mode = do
+ writeFile file (formatPointer k)
+ maybe noop (setFileMode file) mode
{- Parses a symlink target or a pointer file to a Key.
- Only looks at the first line, as pointer files can have subsequent