diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-03-11 12:47:14 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-03-11 12:47:14 -0400 |
commit | 30a5b59abe5c54cc0afbe27f8da3ba8be55b3847 (patch) | |
tree | e9778046dd485eb8dd27fae3e9fde754f07dadd8 /Git/CatFile.hs | |
parent | b15ce31aa84ac2ae3d78e82868fb6065f15c99a4 (diff) |
extract commit parent(s)
Diffstat (limited to 'Git/CatFile.hs')
-rw-r--r-- | Git/CatFile.hs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Git/CatFile.hs b/Git/CatFile.hs index 455f192a0..d6f7707bc 100644 --- a/Git/CatFile.hs +++ b/Git/CatFile.hs @@ -125,15 +125,17 @@ catCommit h commitref = go <$> catObjectDetails h commitref parseCommit :: L.ByteString -> Maybe Commit parseCommit b = Commit <$> (extractSha . L8.unpack =<< field "tree") + <*> (mapMaybe (extractSha . L8.unpack) <$> fields "parent") <*> (parsemetadata <$> field "author") <*> (parsemetadata <$> field "committer") <*> Just (L8.unpack $ L.intercalate (L.singleton nl) message) where - field n = M.lookup (fromString n) fields - fields = M.fromList ((map breakfield) header) + field n = headMaybe =<< fields n + fields n = M.lookup (fromString n) fieldmap + fieldmap = M.fromListWith (++) ((map breakfield) header) breakfield l = let (k, sp_v) = L.break (== sp) l - in (k, L.drop 1 sp_v) + in (k, [L.drop 1 sp_v]) (header, message) = separate L.null ls ls = L.split nl b |