adjust unlocked execute bit handling

When building an adjusted unlocked branch, make pointer files executable
when the annex object file is executable.

This slows down git-annex adjust --unlock/--unlock-present by needing to
stat all annex object files in the tree. Probably not a significant
slowdown compared to other work they do, but I have not benchmarked.

I chose to leave git-annex adjust --unlock marked as stable, even though
get or drop of an object file can change whether it would make the pointer
file executable. Partly because making it unstable would slow down
re-adjustment, and partly for symmetry with the handling of an unlocked
pointer file that is executable when the content is dropped, which does not
remove its execute bit.
This commit is contained in:
Joey Hess 2024-05-28 12:39:42 -04:00
parent 1bb819f597
commit 3318d25c65
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
5 changed files with 40 additions and 3 deletions

View file

@ -1,6 +1,6 @@
{- adjusted branch
-
- Copyright 2016-2023 Joey Hess <id@joeyh.name>
- Copyright 2016-2024 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
-}
@ -68,9 +68,12 @@ import qualified Database.Keys
import Config
import Logs.View (is_branchView)
import Logs.AdjustedBranchUpdate
import Utility.FileMode
import qualified Utility.RawFilePath as R
import Data.Time.Clock.POSIX
import qualified Data.Map as M
import System.PosixCompat.Files (fileMode)
class AdjustTreeItem t where
-- How to perform various adjustments to a TreeItem.
@ -155,8 +158,13 @@ adjustToPointer :: TreeItem -> Annex (Maybe TreeItem)
adjustToPointer ti@(TreeItem f _m s) = catKey s >>= \case
Just k -> do
Database.Keys.addAssociatedFile k f
Just . TreeItem f (fromTreeItemType TreeFile)
<$> hashPointerFile k
exe <- catchDefaultIO False $
(isExecutable . fileMode) <$>
(liftIO . R.getFileStatus
=<< calcRepo (gitAnnexLocation k))
let mode = fromTreeItemType $
if exe then TreeExecutable else TreeFile
Just . TreeItem f mode <$> hashPointerFile k
Nothing -> return (Just ti)
adjustToSymlink :: TreeItem -> Annex (Maybe TreeItem)