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
1081d909
Commit
1081d909
authored
Nov 05, 2010
by
Colin Timmermans
Committed by
Vicent Marti
Nov 07, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix parsing of commits that have no newlines in the message.
parent
4b7483a2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
5 deletions
+24
-5
src/commit.c
+4
-3
tests/t0401-parse.c
+20
-2
No files found.
src/commit.c
View file @
1081d909
...
@@ -176,14 +176,15 @@ int commit_parse_buffer(git_commit *commit, void *data, size_t len, unsigned int
...
@@ -176,14 +176,15 @@ int commit_parse_buffer(git_commit *commit, void *data, size_t len, unsigned int
char
*
line_end
;
char
*
line_end
;
size_t
message_len
=
buffer_end
-
buffer
;
size_t
message_len
=
buffer_end
-
buffer
;
/*
Short
message */
/*
Long
message */
message_len
=
buffer_end
-
buffer
;
message_len
=
buffer_end
-
buffer
;
commit
->
message
=
git__malloc
(
message_len
+
1
);
commit
->
message
=
git__malloc
(
message_len
+
1
);
memcpy
(
commit
->
message
,
buffer
,
message_len
);
memcpy
(
commit
->
message
,
buffer
,
message_len
);
commit
->
message
[
message_len
]
=
0
;
commit
->
message
[
message_len
]
=
0
;
/* Long message */
/* Short message */
line_end
=
memchr
(
buffer
,
'\n'
,
buffer_end
-
buffer
);
if
((
line_end
=
memchr
(
buffer
,
'\n'
,
buffer_end
-
buffer
))
==
NULL
)
line_end
=
buffer_end
;
message_len
=
line_end
-
buffer
;
message_len
=
line_end
-
buffer
;
commit
->
message_short
=
git__malloc
(
message_len
+
1
);
commit
->
message_short
=
git__malloc
(
message_len
+
1
);
...
...
tests/t0401-parse.c
View file @
1081d909
...
@@ -71,11 +71,19 @@ committer Vicent Marti <tanoku@gmail.com> 1273848544 +0200\n\
...
@@ -71,11 +71,19 @@ committer Vicent Marti <tanoku@gmail.com> 1273848544 +0200\n\
\n
\
\n
\
a simple commit which works
\n
"
,
a simple commit which works
\n
"
,
/* simple commit,
1 parents
*/
/* simple commit,
no parent, no newline in message
*/
"tree 1810dff58d8a660512d4832e740f692884338ccd
\n
\
"tree 1810dff58d8a660512d4832e740f692884338ccd
\n
\
author Vicent Marti <tanoku@gmail.com> 1273848544 +0200
\n
\
author Vicent Marti <tanoku@gmail.com> 1273848544 +0200
\n
\
committer Vicent Marti <tanoku@gmail.com> 1273848544 +0200
\n
\
committer Vicent Marti <tanoku@gmail.com> 1273848544 +0200
\n
\
\n
\
\n
\
a simple commit which works"
,
/* simple commit, 1 parent */
"tree 1810dff58d8a660512d4832e740f692884338ccd
\n
\
parent e90810b8df3e80c413d903f631643c716887138d
\n
\
author Vicent Marti <tanoku@gmail.com> 1273848544 +0200
\n
\
committer Vicent Marti <tanoku@gmail.com> 1273848544 +0200
\n
\
\n
\
a simple commit which works
\n
"
,
a simple commit which works
\n
"
,
};
};
...
@@ -210,7 +218,7 @@ BEGIN_TEST(parse_person_test)
...
@@ -210,7 +218,7 @@ BEGIN_TEST(parse_person_test)
"author "
);
"author "
);
#undef TEST_PERSON_PASS
#undef TEST_PERSON_PASS
#undef TES
t
_PERSON_FAIL
#undef TES
T
_PERSON_FAIL
END_TEST
END_TEST
...
@@ -252,6 +260,16 @@ BEGIN_TEST(parse_buffer_test)
...
@@ -252,6 +260,16 @@ BEGIN_TEST(parse_buffer_test)
commit
,
commit
,
test_commits_working
[
i
],
test_commits_working
[
i
],
strlen
(
test_commits_working
[
i
]),
strlen
(
test_commits_working
[
i
]),
0x0
)
);
memset
(
commit
,
0x0
,
sizeof
(
git_commit
));
commit
->
object
.
repo
=
repo
;
must_pass
(
commit_parse_buffer
(
commit
,
test_commits_working
[
i
],
strlen
(
test_commits_working
[
i
]),
0x1
)
0x1
)
);
);
...
...
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