From 681d8611be4108edcde11fc69a47e399218e536b Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 14 Dec 2021 13:51:00 -0400 Subject: [PATCH] fix flush order reversion commit c2e46f470707681bf0398662afb047b1b48baec3 caused the queue to possibly be flushed in the wrong order when it contained a mix of different actions. --- Git/Queue.hs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Git/Queue.hs b/Git/Queue.hs index 9987db56bd..495383e09c 100644 --- a/Git/Queue.hs +++ b/Git/Queue.hs @@ -169,11 +169,16 @@ updateQueue :: MonadIO m => Action m -> (Action m -> Bool) -> Int -> Queue m -> updateQueue !action different sizeincrease q repo = do now <- liftIO getPOSIXTime if now - (_lastchanged q) > _timelimit q - then flush (mk q) repo - else if null (filter different (M.elems (items q))) - then return $ mk (q { _lastchanged = now }) - else mk <$> flush q repo + then if isdifferent + then do + q' <- flush q repo + flush (mk q') repo + else flush (mk q) repo + else if isdifferent + then mk <$> flush q repo + else return $ mk (q { _lastchanged = now }) where + isdifferent = not (null (filter different (M.elems (items q)))) mk q' = newq where !newq = q'