From 8d607c894f8bfae17f6e4f5df81ce1c7decf9fa9 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 31 Oct 2016 18:35:38 -0400 Subject: Fix reversion in 6.20161012 that prevented adding files with a space in their name. --- Git/CatFile.hs | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'Git') diff --git a/Git/CatFile.hs b/Git/CatFile.hs index a377a08f7..9af46fb51 100644 --- a/Git/CatFile.hs +++ b/Git/CatFile.hs @@ -109,17 +109,18 @@ query hdl object receive = CoProcess.query hdl send receive send to = hPutStrLn to (fromRef object) parseResp :: Ref -> String -> Maybe ParsedResp -parseResp object l = case words l of - [sha, objtype, size] - | length sha == shaSize -> - case (readObjectType objtype, reads size) of - (Just t, [(bytes, "")]) -> - Just $ ParsedResp (Ref sha) bytes t - _ -> Nothing - | otherwise -> Nothing - _ - | l == fromRef object ++ " missing" -> Just DNE - | otherwise -> Nothing +parseResp object l + | " missing" `isSuffixOf` l -- less expensive than full check + && l == fromRef object ++ " missing" = Just DNE + | otherwise = case words l of + [sha, objtype, size] + | length sha == shaSize -> + case (readObjectType objtype, reads size) of + (Just t, [(bytes, "")]) -> + Just $ ParsedResp (Ref sha) bytes t + _ -> Nothing + | otherwise -> Nothing + _ -> Nothing {- Gets a list of files and directories in a tree. (Not recursive.) -} catTree :: CatFileHandle -> Ref -> IO [(FilePath, FileMode)] -- cgit v1.2.3