aboutsummaryrefslogtreecommitdiff
path: root/Command/Fix.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 /Command/Fix.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 'Command/Fix.hs')
-rw-r--r--Command/Fix.hs6
1 files changed, 4 insertions, 2 deletions
diff --git a/Command/Fix.hs b/Command/Fix.hs
index d87bea358..3a153c761 100644
--- a/Command/Fix.hs
+++ b/Command/Fix.hs
@@ -67,7 +67,8 @@ start fixwhat file key = do
breakHardLink :: FilePath -> Key -> FilePath -> CommandPerform
breakHardLink file key obj = do
replaceFile file $ \tmp -> do
- unlessM (checkedCopyFile key obj tmp) $
+ mode <- liftIO $ catchMaybeIO $ fileMode <$> getFileStatus file
+ unlessM (checkedCopyFile key obj tmp mode) $
error "unable to break hard link"
thawContent tmp
modifyContent obj $ freezeContent obj
@@ -77,7 +78,8 @@ breakHardLink file key obj = do
makeHardLink :: FilePath -> Key -> CommandPerform
makeHardLink file key = do
replaceFile file $ \tmp -> do
- r <- linkFromAnnex key tmp
+ mode <- liftIO $ catchMaybeIO $ fileMode <$> getFileStatus file
+ r <- linkFromAnnex key tmp mode
case r of
LinkAnnexFailed -> error "unable to make hard link"
_ -> noop