Commit 3e0ee6b5 authored by Russ Cox's avatar Russ Cox

patch: handle text diffs from git

R=r
CC=golang-dev
https://golang.org/cl/194094
parent dd97923d
......@@ -207,7 +207,7 @@ func Parse(text []byte) (*Set, os.Error) {
p.Diff = diff
break
}
if hasPrefix(l, "index ") || hasPrefix(l, "GIT binary patch") {
if hasPrefix(l, "GIT binary patch") || (hasPrefix(l, "index ") && !hasPrefix(raw, "--- ")) {
diff, err := ParseGitBinary(oldraw)
if err != nil {
return nil, err
......@@ -215,6 +215,9 @@ func Parse(text []byte) (*Set, os.Error) {
p.Diff = diff
break
}
if hasPrefix(l, "index ") {
continue
}
return nil, SyntaxError("unexpected patch header line: " + string(l))
}
if p.Diff == nil {
......
......@@ -50,6 +50,17 @@ var tests = []Test{
"-hello, world\n" +
"+goodbye, world\n",
},
Test{
"hello, world\n",
"goodbye, world\n",
"Index: a\n" +
"index cb34d9b1743b7c410fa750be8a58eb355987110b..0a01764bc1b2fd29da317f72208f462ad342400f\n" +
"--- a/a\n" +
"+++ b/b\n" +
"@@ -1 +1 @@\n" +
"-hello, world\n" +
"+goodbye, world\n",
},
Test{
"hello, world\n",
"goodbye, world\n",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment