aboutsummaryrefslogtreecommitdiffstats
path: root/diff-parse.patch
blob: d3fac037f57139f86b6deb3f0a4a7416e2966810 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
diff --git a/src/Text/Diff/Parse/Internal.hs b/src/Text/Diff/Parse/Internal.hs
index 99302b8..715686c 100644
--- a/src/Text/Diff/Parse/Internal.hs
+++ b/src/Text/Diff/Parse/Internal.hs
@@ -50,12 +50,12 @@ fileDelta = do
 fileDeltaHeader :: Parser (FileStatus, Text, Text)
 fileDeltaHeader = do
     _      <- string "diff --git "
-    source <- path <* space
-    dest   <- path <* endOfLine
+    _      <- path <* space
+    _      <- path <* endOfLine
     status <- fileStatus
     _      <- option "" (string "index" >> takeLine)
-    _      <- option "" (string "--- " >> takeLine)
-    _      <- option "" (string "+++ " >> takeLine)
+    source <- string "--- " >> path <* endOfLine
+    dest   <- string "+++ " >> path <* endOfLine
     return $ (status, source, dest)
 
 takeLine :: Parser Text
@@ -97,3 +97,4 @@ annotation :: Parser Annotation
 annotation = (char '+' >> return Added)
          <|> (char '-' >> return Removed)
          <|> (char ' ' >> return Context)
+         <|> (char '#' >> return Comment)
diff --git a/src/Text/Diff/Parse/Types.hs b/src/Text/Diff/Parse/Types.hs
index a658ae4..3901575 100644
--- a/src/Text/Diff/Parse/Types.hs
+++ b/src/Text/Diff/Parse/Types.hs
@@ -2,7 +2,7 @@ module Text.Diff.Parse.Types where
 
 import Data.Text (Text)
 
-data Annotation = Added | Removed | Context deriving (Show, Eq)
+data Annotation = Added | Removed | Context | Comment deriving (Show, Eq)
 
 data Line = Line {
     lineAnnotation :: Annotation