Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
c9464bf7
Unverified
Commit
c9464bf7
authored
Oct 17, 2019
by
Patrick Steinhardt
Committed by
GitHub
Oct 17, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5273 from dlax/parse-diff-without-extended-headers
patch_parse: handle patches without extended headers
parents
4c0dea5a
11de594f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
0 deletions
+21
-0
src/patch_parse.c
+1
-0
tests/diff/parse.c
+10
-0
tests/patch/patch_common.h
+10
-0
No files found.
src/patch_parse.c
View file @
c9464bf7
...
...
@@ -389,6 +389,7 @@ static const parse_header_transition transitions[] = {
{
"index "
,
STATE_DIFF
,
STATE_INDEX
,
parse_header_git_index
},
{
"index "
,
STATE_END
,
STATE_INDEX
,
parse_header_git_index
},
{
"--- "
,
STATE_DIFF
,
STATE_PATH
,
parse_header_git_oldpath
},
{
"--- "
,
STATE_INDEX
,
STATE_PATH
,
parse_header_git_oldpath
},
{
"+++ "
,
STATE_PATH
,
STATE_END
,
parse_header_git_newpath
},
{
"GIT binary patch"
,
STATE_INDEX
,
STATE_END
,
NULL
},
...
...
tests/diff/parse.c
View file @
c9464bf7
...
...
@@ -98,6 +98,16 @@ void test_diff_parse__empty_file(void)
git_diff_free
(
diff
);
}
void
test_diff_parse__no_extended_headers
(
void
)
{
const
char
*
content
=
PATCH_NO_EXTENDED_HEADERS
;
git_diff
*
diff
;
cl_git_pass
(
git_diff_from_buffer
(
&
diff
,
content
,
strlen
(
content
)));
git_diff_free
(
diff
);
}
void
test_diff_parse__invalid_patches_fails
(
void
)
{
test_parse_invalid_diff
(
PATCH_CORRUPT_MISSING_NEW_FILE
);
...
...
tests/patch/patch_common.h
View file @
c9464bf7
...
...
@@ -895,3 +895,13 @@
"+++ b/test-file\r\n" \
"@@ -0,0 +1 @@\r\n" \
"+a contents\r\n"
#define PATCH_NO_EXTENDED_HEADERS \
"diff --git a/file b/file\n" \
"--- a/file\n" \
"+++ b/file\n" \
"@@ -1,3 +1,3 @@\n" \
" a\n" \
"-b\n" \
"+bb\n" \
" c\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