rkneufeld/unified_diff — pull request #7 by dkempiners (2014-08-03 19:12:56+00:00)
Title: only match new/old file pattern at the beginning of a line

Some diff lines that include the patterns "--- " or "+++ " are being mistakenly identified as the diff header (new/old file). Since these lines don't get include in the chunk, there ends up being a mismatch being the header and the contents which prevents a chunk from being applied.

```
chunk = <<-'CHUNK'.unindent
@@ -0,0 +1,5 @@
++++++++ ++++++ +++
++ some heading
+ stuff +++++++++ stuff
++++ a
+some body
CHUNK

@diff = UnifiedDiff.parse(header + chunk)
@chunk = @diff.chunks.first
puts @chunk

> cat test.diff
--- test.out
+++ test.out
@@ -0,0 +1,5 @@
++ some heading
+some body

> patch < test.diff
patching file test.out
patch: **** malformed patch at line 5:
```