summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Command/Log.hs7
-rw-r--r--Git/LsFiles.hs20
2 files changed, 14 insertions, 13 deletions
diff --git a/Command/Log.hs b/Command/Log.hs
index 09d22b2ef..90d3d9490 100644
--- a/Command/Log.hs
+++ b/Command/Log.hs
@@ -159,11 +159,10 @@ readLog = mapMaybe (parse . lines)
-- Parses something like ":100644 100644 oldsha newsha M"
parseRaw :: String -> (Git.Ref, Git.Ref)
-parseRaw l = (Git.Ref oldsha, Git.Ref newsha)
+parseRaw l = go $ words l
where
- ws = words l
- oldsha = ws !! 2
- newsha = ws !! 3
+ go (_:_:oldsha:newsha:_) = (Git.Ref oldsha, Git.Ref newsha)
+ go _ = error $ "unable to parse git log output: " ++ l
parseTimeStamp :: String -> POSIXTime
parseTimeStamp = utcTimeToPOSIXSeconds . fromMaybe (error "bad timestamp") .
diff --git a/Git/LsFiles.hs b/Git/LsFiles.hs
index 5dd988fc3..4f8ac3fc6 100644
--- a/Git/LsFiles.hs
+++ b/Git/LsFiles.hs
@@ -120,17 +120,19 @@ data InternalUnmerged = InternalUnmerged
parseUnmerged :: String -> Maybe InternalUnmerged
parseUnmerged s
- | null file || length ws < 3 = Nothing
- | otherwise = do
- stage <- readish (ws !! 2) :: Maybe Int
- unless (stage == 2 || stage == 3) $
- fail undefined -- skip stage 1
- blobtype <- readBlobType (ws !! 0)
- sha <- extractSha (ws !! 1)
- return $ InternalUnmerged (stage == 2) file (Just blobtype) (Just sha)
+ | null file = Nothing
+ | otherwise = case words metadata of
+ (rawblobtype:rawsha:rawstage:_) -> do
+ stage <- readish rawstage :: Maybe Int
+ unless (stage == 2 || stage == 3) $
+ fail undefined -- skip stage 1
+ blobtype <- readBlobType rawblobtype
+ sha <- extractSha rawsha
+ return $ InternalUnmerged (stage == 2) file
+ (Just blobtype) (Just sha)
+ _ -> Nothing
where
(metadata, file) = separate (== '\t') s
- ws = words metadata
reduceUnmerged :: [Unmerged] -> [InternalUnmerged] -> [Unmerged]
reduceUnmerged c [] = c