]> dgit.raspbian.org Git - git-annex.git/commitdiff
reorg
authorJoey Hess <joeyh@joeyh.name>
Thu, 4 Nov 2021 19:03:12 +0000 (15:03 -0400)
committerJoey Hess <joeyh@joeyh.name>
Thu, 4 Nov 2021 19:03:12 +0000 (15:03 -0400)
Git/FilterProcess.hs
Git/PktLine.hs

index b3bcfe12f33212635ec691020c04ce220943674c..57541a0b7355a0c835c8ebc5b60beee1c60f649f 100644 (file)
@@ -14,9 +14,6 @@ module Git.FilterProcess (
        WelcomeMessage(..),
        Version(..),
        Capability(..),
-       readUntilFlushPkt,
-       readUntilFlushPktOrSize,
-       discardUntilFlushPkt,
        longRunningProcessHandshake,
        longRunningFilterProcessHandshake,
        FilterRequest(..),
@@ -77,40 +74,6 @@ decodeCapability pktline = decodeConfigValue pktline >>= \case
        ConfigValue "capability" c -> Just $ Capability c
        _ -> Nothing
 
-{- Reads PktLines until a flushPkt (or EOF), 
- - and returns all except the flushPkt -}
-readUntilFlushPkt :: IO [PktLine]
-readUntilFlushPkt = go []
-  where
-       go l = readPktLine stdin >>= \case
-               Just pktline | not (isFlushPkt pktline) -> go (pktline:l)
-               _ -> return (reverse l)
-
-{- Reads PktLines until at least the specified number of bytes have been
- - read, or until a flushPkt (or EOF). Returns Right if it did read a
- - flushPkt/EOF, and Left if there is still content leftover that needs to
- - be read. -}
-readUntilFlushPktOrSize :: Int -> IO (Either [PktLine] [PktLine])
-readUntilFlushPktOrSize = go []
-  where
-       go l n = readPktLine stdin >>= \case
-               Just pktline
-                       | isFlushPkt pktline -> return (Right (reverse l))
-                       | otherwise -> 
-                               let len = B.length (pktLineToByteString pktline)
-                                   n' = n - len
-                               in if n' <= 0
-                                       then return (Left (reverse (pktline:l)))
-                                       else go (pktline:l) n'
-               Nothing -> return (Right (reverse l))
-
-{- Reads PktLines until a flushPkt (or EOF), and throws them away. -}
-discardUntilFlushPkt :: IO ()
-discardUntilFlushPkt = readPktLine stdin >>= \case
-       Just pktline | isFlushPkt pktline -> return ()
-       Nothing -> return ()
-       _ -> discardUntilFlushPkt
-
 longRunningProcessHandshake
        :: (WelcomeMessage -> Maybe WelcomeMessage)
        -> ([Version] -> [Version])
index 29af14c7526b7b73723a2a5200c18c883db329fc..844d3d6a26c0ac415fc6d31c04ed332399e52ed4 100644 (file)
@@ -19,6 +19,9 @@ module Git.PktLine (
        writePktLine,
        flushPkt,
        isFlushPkt,
+       readUntilFlushPkt,
+       readUntilFlushPktOrSize,
+       discardUntilFlushPkt,
 ) where
 
 import System.IO
@@ -115,3 +118,37 @@ flushPkt = PktLine mempty
 
 isFlushPkt :: PktLine -> Bool
 isFlushPkt (PktLine b) = b == mempty
+
+{- Reads PktLines until a flushPkt (or EOF), 
+ - and returns all except the flushPkt -}
+readUntilFlushPkt :: IO [PktLine]
+readUntilFlushPkt = go []
+  where
+       go l = readPktLine stdin >>= \case
+               Just pktline | not (isFlushPkt pktline) -> go (pktline:l)
+               _ -> return (reverse l)
+
+{- Reads PktLines until at least the specified number of bytes have been
+ - read, or until a flushPkt (or EOF). Returns Right if it did read a
+ - flushPkt/EOF, and Left if there is still content leftover that needs to
+ - be read. -}
+readUntilFlushPktOrSize :: Int -> IO (Either [PktLine] [PktLine])
+readUntilFlushPktOrSize = go []
+  where
+       go l n = readPktLine stdin >>= \case
+               Just pktline
+                       | isFlushPkt pktline -> return (Right (reverse l))
+                       | otherwise -> 
+                               let len = B.length (pktLineToByteString pktline)
+                                   n' = n - len
+                               in if n' <= 0
+                                       then return (Left (reverse (pktline:l)))
+                                       else go (pktline:l) n'
+               Nothing -> return (Right (reverse l))
+
+{- Reads PktLines until a flushPkt (or EOF), and throws them away. -}
+discardUntilFlushPkt :: IO ()
+discardUntilFlushPkt = readPktLine stdin >>= \case
+       Just pktline | isFlushPkt pktline -> return ()
+       Nothing -> return ()
+       _ -> discardUntilFlushPkt