avoid catObjectStream skipping over unavailable shas

Not needed as it's used for --all, but will be needed later.
This commit is contained in:
Joey Hess 2020-07-08 13:56:14 -04:00
parent de3d7d044d
commit d08c178f97
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
3 changed files with 10 additions and 18 deletions

View file

@ -295,7 +295,7 @@ catObjectStream
=> [LsTree.TreeItem]
-> (LsTree.TreeItem -> Bool)
-> Repo
-> (IO (Maybe (TopFilePath, L.ByteString)) -> m ())
-> (IO (Maybe (TopFilePath, Maybe L.ByteString)) -> m ())
-> m ()
catObjectStream l want repo a = assertLocal repo $ do
bracketIO start stop $ \(mv, _, _, hout, _) -> a (reader mv hout)
@ -304,19 +304,21 @@ catObjectStream l want repo a = assertLocal repo $ do
forM_ l $ \ti ->
when (want ti) $ do
let f = LsTree.file ti
liftIO $ atomically $ snocTList mv f
S8.hPutStrLn h (fromRef' (LsTree.sha ti))
let sha = LsTree.sha ti
liftIO $ atomically $ snocTList mv (sha, f)
S8.hPutStrLn h (fromRef' sha)
hClose h
reader mv h = ifM (hIsEOF h)
( return Nothing
, do
f <- liftIO $ atomically $ headTList mv
(sha, f) <- liftIO $ atomically $ headTList mv
resp <- S8.hGetLine h
case eitherToMaybe $ A.parseOnly respParser resp of
Just r -> do
case parseResp sha resp of
Just r@(ParsedResp {}) -> do
content <- readObjectContent h r
return (Just (f, content))
return (Just (f, Just content))
Just DNE -> return (Just (f, Nothing))
Nothing -> error $ "unknown response from git cat-file " ++ show resp
)