Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
3e0ee6b5
Commit
3e0ee6b5
authored
Jan 27, 2010
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
patch: handle text diffs from git
R=r CC=golang-dev
https://golang.org/cl/194094
parent
dd97923d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
1 deletion
+15
-1
patch.go
src/pkg/patch/patch.go
+4
-1
patch_test.go
src/pkg/patch/patch_test.go
+11
-0
No files found.
src/pkg/patch/patch.go
View file @
3e0ee6b5
...
@@ -207,7 +207,7 @@ func Parse(text []byte) (*Set, os.Error) {
...
@@ -207,7 +207,7 @@ func Parse(text []byte) (*Set, os.Error) {
p
.
Diff
=
diff
p
.
Diff
=
diff
break
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
)
diff
,
err
:=
ParseGitBinary
(
oldraw
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -215,6 +215,9 @@ func Parse(text []byte) (*Set, os.Error) {
...
@@ -215,6 +215,9 @@ func Parse(text []byte) (*Set, os.Error) {
p
.
Diff
=
diff
p
.
Diff
=
diff
break
break
}
}
if
hasPrefix
(
l
,
"index "
)
{
continue
}
return
nil
,
SyntaxError
(
"unexpected patch header line: "
+
string
(
l
))
return
nil
,
SyntaxError
(
"unexpected patch header line: "
+
string
(
l
))
}
}
if
p
.
Diff
==
nil
{
if
p
.
Diff
==
nil
{
...
...
src/pkg/patch/patch_test.go
View file @
3e0ee6b5
...
@@ -50,6 +50,17 @@ var tests = []Test{
...
@@ -50,6 +50,17 @@ var tests = []Test{
"-hello, world
\n
"
+
"-hello, world
\n
"
+
"+goodbye, 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
{
Test
{
"hello, world
\n
"
,
"hello, world
\n
"
,
"goodbye, world
\n
"
,
"goodbye, world
\n
"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment