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

@ -23,7 +23,7 @@ import qualified Git.Merge
import qualified Git.Ref
import qualified Git
import qualified Git.Branch
import Git.Types (BlobType(..))
import Git.Types (BlobType(..), fromBlobType)
import Git.FilePath
import Config
import Annex.ReplaceFile
@ -31,6 +31,7 @@ import Annex.VariantFile
import qualified Database.Keys
import Annex.InodeSentinal
import Utility.InodeCache
import Utility.FileMode
import qualified Data.Set as S
import qualified Data.Map as M
@ -152,12 +153,12 @@ resolveMerge' unstagedmap (Just us) them inoverlay u = do
-- In either case, keep original filename.
if islocked LsFiles.valUs && islocked LsFiles.valThem
then makesymlink keyUs file
else makepointer keyUs file
else makepointer keyUs file (combinedmodes)
return ([keyUs, keyThem], Just file)
-- Our side is annexed file, other side is not.
(Just keyUs, Nothing) -> resolveby [keyUs] $ do
graftin them file LsFiles.valThem LsFiles.valThem LsFiles.valUs
makeannexlink keyUs LsFiles.valUs
makeannexlink keyUs LsFiles.valUs
-- Our side is not annexed file, other side is.
(Nothing, Just keyThem) -> resolveby [keyThem] $ do
graftin us file LsFiles.valUs LsFiles.valUs LsFiles.valThem
@ -174,11 +175,19 @@ resolveMerge' unstagedmap (Just us) them inoverlay u = do
islocked select = select (LsFiles.unmergedBlobType u) == Just SymlinkBlob
combinedmodes = case catMaybes [ourmode, theirmode] of
[] -> Nothing
l -> Just (combineModes l)
where
ourmode = fromBlobType <$> LsFiles.valUs (LsFiles.unmergedBlobType u)
theirmode = fromBlobType <$> LsFiles.valThem (LsFiles.unmergedBlobType u)
makeannexlink key select
| islocked select = makesymlink key dest
| otherwise = makepointer key dest
| otherwise = makepointer key dest destmode
where
dest = variantFile file key
destmode = fromBlobType <$> select (LsFiles.unmergedBlobType u)
stagefile :: FilePath -> Annex FilePath
stagefile f
@ -194,16 +203,16 @@ resolveMerge' unstagedmap (Just us) them inoverlay u = do
replacewithsymlink dest link = withworktree dest $ \f ->
replaceFile f $ makeGitLink link
makepointer key dest = do
makepointer key dest destmode = do
unless inoverlay $
unlessM (reuseOldFile unstagedmap key file dest) $ do
r <- linkFromAnnex key dest
r <- linkFromAnnex key dest destmode
case r of
LinkAnnexFailed -> liftIO $
writeFile dest (formatPointer key)
writePointerFile dest key destmode
_ -> noop
dest' <- stagefile dest
stagePointerFile dest' =<< hashPointerFile key
stagePointerFile dest' destmode =<< hashPointerFile key
unless inoverlay $
Database.Keys.addAssociatedFile key
=<< inRepo (toTopFilePath dest)