6d7ecd9e5d
Improved support for using git-annex in a read-only repository, git-annex branch information from remotes that cannot be merged into the git-annex branch will now not crash it, but will be merged in memory. To avoid this making git-annex behave one way in a read-only repository, and another way when it can write, it's important that Annex.Branch.get return the same thing (modulo log file compaction) in both cases. This manages that mostly. There are some exceptions: - When there is a transition in one of the remote git-annex branches that has not yet been applied to the local or other git-annex branches. Transitions are not handled. - `git-annex log` runs git log on the git-annex branch, and so it will not be able to show information coming from the other, not yet merged branches. - Annex.Branch.files only looks at files in the git-annex branch and not unmerged branches. This affects git-annex info output. - Annex.Branch.hs.overBranchFileContents ditto. Affects --all and also importfeed (but importfeed cannot work in a read-only repo anyway). - CmdLine.Seek.seekFilteredKeys when precaching location logs. Note use of Annex.Branch.fullname - Database.ContentIdentifier.needsUpdateFromLog and updateFromLog These warts make this not suitable to be merged yet. This readonly code path is more expensive, since it has to query several branches. The value does get cached, but still large queries will be slower in a read-only repository when there are unmerged git-annex branches. When annex.merge-annex-branches=false, updateTo skips doing anything, and so the read-only repository code does not get triggered. So a user who is bothered by the extra work can set that. Other writes to the repository can still result in permissions errors. This includes the initial creation of the git-annex branch, and of course any writes to the git-annex branch. Sponsored-by: Dartmouth College's Datalad project
38 lines
1.3 KiB
Haskell
38 lines
1.3 KiB
Haskell
{- git-annex BranchState data type
|
|
-
|
|
- Copyright 2011-2021 Joey Hess <id@joeyh.name>
|
|
-
|
|
- Licensed under the GNU AGPL version 3 or higher.
|
|
-}
|
|
|
|
module Types.BranchState where
|
|
|
|
import Common
|
|
import qualified Git
|
|
|
|
import qualified Data.ByteString.Lazy as L
|
|
|
|
data BranchState = BranchState
|
|
{ branchUpdated :: Bool
|
|
-- ^ has the branch been updated this run? (Or an update tried and
|
|
-- failed due to permissions.)
|
|
, indexChecked :: Bool
|
|
-- ^ has the index file been checked to exist?
|
|
, journalIgnorable :: Bool
|
|
-- ^ can reading the journal be skipped, while still getting
|
|
-- sufficiently up-to-date information from the branch?
|
|
, unmergedRefs :: [Git.Sha]
|
|
-- ^ when the branch was not able to be updated due to permissions,
|
|
-- these other git refs contain unmerged information and need to be
|
|
-- queried, along with the index and the journal.
|
|
, cachedFileContents :: [(RawFilePath, L.ByteString)]
|
|
-- ^ contents of a few files recently read from the branch
|
|
, needInteractiveAccess :: Bool
|
|
-- ^ do new changes written to the journal or branch by another
|
|
-- process need to be noticed while the current process is running?
|
|
-- (This makes the journal always be read, and avoids using the
|
|
-- cache.)
|
|
}
|
|
|
|
startBranchState :: BranchState
|
|
startBranchState = BranchState False False False [] [] False
|