branchref <- getBranch
ignoredrefs <- getIgnoredRefs
let unignoredrefs = excludeset ignoredrefs pairs
- tomerge <- if null unignoredrefs
- then return []
+ (tomerge, notnewer) <- if null unignoredrefs
+ then return ([], [])
else do
mergedrefs <- getMergedRefs
- filterM isnewer (excludeset mergedrefs unignoredrefs)
+ partitionM isnewer $
+ excludeset mergedrefs unignoredrefs
{- In a read-only repository, catching permission denied lets
- query operations still work, although they will need to do
- additional work since the refs are not merged. -}
catchPermissionDenied
(const (updatefailedperms tomerge))
- (go branchref tomerge)
+ (go branchref tomerge notnewer)
where
excludeset s = filter (\(r, _) -> S.notMember r s)
isnewer (r, _) = inRepo $ Git.Branch.changed fullname r
- go branchref tomerge = do
+ go branchref tomerge notnewer = do
dirty <- journalDirty gitAnnexJournalDir
journalcleaned <- if null tomerge
{- Even when no refs need to be merged, the index
journalclean <- if journalcleaned
then not <$> privateUUIDsKnown
else pure False
+ addMergedRefs notnewer
return $ UpdateMade
{ refsWereMerged = not (null tomerge)
, journalClean = journalclean
* Fix behavior of onlyingroup.
* info: Added --dead-repositories option.
+ * Significant startup speed increase by avoiding repeatedly checking
+ if some remote git-annex branch refs need to be merged.
-- Joey Hess <id@joeyh.name> Mon, 07 Aug 2023 13:04:13 -0400
getM,
anyM,
allM,
+ partitionM,
untilTrue,
ifM,
(<||>),
allM _ [] = return True
allM p (x:xs) = p x <&&> allM p xs
+partitionM :: Monad m => (a -> m Bool) -> [a] -> m ([a], [a])
+partitionM _ [] = return ([], [])
+partitionM p (x:xs) = do
+ r <- p x
+ (as, bs) <- partitionM p xs
+ return $ if r then (x:as, bs) else (as, x:bs)
+
{- Runs an action on values from a list until it succeeds. -}
untilTrue :: Monad m => [a] -> (a -> m Bool) -> m Bool
untilTrue = flip anyM