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
ed959ca2
Unverified
Commit
ed959ca2
authored
Apr 16, 2019
by
Patrick Steinhardt
Committed by
GitHub
Apr 16, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5027 from ddevault/master
patch_parse.c: Handle CRLF in parse_header_start
parents
d1cfd79a
30c06b60
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
1 deletions
+30
-1
src/patch_parse.c
+2
-1
tests/diff/parse.c
+19
-0
tests/patch/patch_common.h
+9
-0
No files found.
src/patch_parse.c
View file @
ed959ca2
...
...
@@ -328,7 +328,8 @@ static int parse_header_start(git_patch_parsed *patch, git_patch_parse_ctx *ctx)
* proceeed here. We then hope for the "---" and "+++" lines to fix that
* for us.
*/
if
(
!
git_parse_ctx_contains
(
&
ctx
->
parse_ctx
,
"
\n
"
,
1
))
{
if
(
!
git_parse_ctx_contains
(
&
ctx
->
parse_ctx
,
"
\n
"
,
1
)
&&
!
git_parse_ctx_contains
(
&
ctx
->
parse_ctx
,
"
\r\n
"
,
2
))
{
git_parse_advance_chars
(
&
ctx
->
parse_ctx
,
ctx
->
parse_ctx
.
line_len
-
1
);
git__free
(
patch
->
header_old_path
);
...
...
tests/diff/parse.c
View file @
ed959ca2
...
...
@@ -360,6 +360,7 @@ void test_diff_parse__lineinfo(void)
git_diff_free
(
diff
);
}
void
test_diff_parse__new_file_with_space
(
void
)
{
const
char
*
content
=
PATCH_ORIGINAL_NEW_FILE_WITH_SPACE
;
...
...
@@ -377,3 +378,21 @@ void test_diff_parse__new_file_with_space(void)
git_patch_free
(
patch
);
git_diff_free
(
diff
);
}
void
test_diff_parse__crlf
(
void
)
{
const
char
*
text
=
PATCH_CRLF
;
git_diff
*
diff
;
git_patch
*
patch
;
const
git_diff_delta
*
delta
;
cl_git_pass
(
git_diff_from_buffer
(
&
diff
,
text
,
strlen
(
text
)));
cl_git_pass
(
git_patch_from_diff
(
&
patch
,
diff
,
0
));
delta
=
git_patch_get_delta
(
patch
);
cl_assert_equal_s
(
delta
->
old_file
.
path
,
"test-file"
);
cl_assert_equal_s
(
delta
->
new_file
.
path
,
"test-file"
);
git_patch_free
(
patch
);
git_diff_free
(
diff
);
}
tests/patch/patch_common.h
View file @
ed959ca2
...
...
@@ -850,3 +850,12 @@
"+++ b/sp ace.txt\n" \
"@@ -0,0 +1 @@\n" \
"+a\n"
#define PATCH_CRLF \
"diff --git a/test-file b/test-file\r\n" \
"new file mode 100644\r\n" \
"index 0000000..af431f2 100644\r\n" \
"--- /dev/null\r\n" \
"+++ b/test-file\r\n" \
"@@ -0,0 +1 @@\r\n" \
"+a contents\r\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