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
2d2260da
Commit
2d2260da
authored
Apr 15, 2013
by
Vicent Martí
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1467 from carlosmn/commit-parse
commit: correctly detect the start of the commit message
parents
041ed367
0efae3b2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
3 deletions
+30
-3
src/commit.c
+2
-2
tests-clar/commit/parse.c
+28
-1
No files found.
src/commit.c
View file @
2d2260da
...
...
@@ -189,8 +189,8 @@ int git_commit__parse_buffer(git_commit *commit, const void *data, size_t len)
buffer
=
eoln
;
}
/*
skip blank lines
*/
while
(
buffer
<
buffer_end
-
1
&&
*
buffer
==
'\n'
)
/*
buffer is now at the end of the header, double-check and move forward into the message
*/
if
(
buffer
<
buffer_end
&&
*
buffer
==
'\n'
)
buffer
++
;
/* parse commit message */
...
...
tests-clar/commit/parse.c
View file @
2d2260da
...
...
@@ -297,7 +297,7 @@ void test_commit_parse__entire_commit(void)
);
if
(
!
i
)
cl_assert_equal_s
(
"
\n
"
,
git_commit_message
(
commit
));
cl_assert_equal_s
(
""
,
git_commit_message
(
commit
));
else
cl_assert
(
git__prefixcmp
(
git_commit_message
(
commit
),
"a simple commit which works"
)
==
0
);
...
...
@@ -366,3 +366,30 @@ void test_commit_parse__details0(void) {
}
}
void
test_commit_parse__leading_lf
(
void
)
{
git_commit
*
commit
;
const
char
*
buffer
=
"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
\
\n
\
\n
\
This commit has a few LF at the start of the commit message"
;
const
char
*
message
=
"
\n
\
\n
\
This commit has a few LF at the start of the commit message"
;
commit
=
(
git_commit
*
)
git__malloc
(
sizeof
(
git_commit
));
memset
(
commit
,
0x0
,
sizeof
(
git_commit
));
commit
->
object
.
repo
=
g_repo
;
cl_git_pass
(
git_commit__parse_buffer
(
commit
,
buffer
,
strlen
(
buffer
)));
cl_assert_equal_s
(
message
,
git_commit_message
(
commit
));
git_commit__free
(
commit
);
}
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