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
62e237e0
Commit
62e237e0
authored
Mar 17, 2016
by
Edward Thomson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3693 from libgit2/cmn/extract-oneline-sig
commit: fix extraction of single-line signatures
parents
de143efa
bf804d40
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
1 deletions
+25
-1
src/commit.c
+1
-1
tests/commit/parse.c
+24
-0
No files found.
src/commit.c
View file @
62e237e0
...
...
@@ -726,7 +726,7 @@ int git_commit_extract_signature(git_buf *signature, git_buf *signed_data, git_r
buf
=
git_odb_object_data
(
obj
);
while
((
h
=
strchr
(
buf
,
'\n'
))
&&
h
[
1
]
!=
'\0'
&&
h
[
1
]
!=
'\n'
)
{
while
((
h
=
strchr
(
buf
,
'\n'
))
&&
h
[
1
]
!=
'\0'
)
{
h
++
;
if
(
git__prefixcmp
(
buf
,
field
))
{
if
(
git_buf_put
(
signed_data
,
buf
,
h
-
buf
)
<
0
)
...
...
tests/commit/parse.c
View file @
62e237e0
...
...
@@ -498,6 +498,21 @@ committer Ben Burkert <ben@benburkert.com> 1358451456 -0800\n\
\n
\
a simple commit which works
\n
"
;
const
char
*
oneline_signature
=
"tree 51832e6397b30309c8bcad9c55fa6ae67778f378
\n
\
parent a1b6decaaac768b5e01e1b5dbf5b2cc081bed1eb
\n
\
author Some User <someuser@gmail.com> 1454537944 -0700
\n
\
committer Some User <someuser@gmail.com> 1454537944 -0700
\n
\
gpgsig bad
\n
\
\n
\
corrupt signature
\n
"
;
const
char
*
oneline_data
=
"tree 51832e6397b30309c8bcad9c55fa6ae67778f378
\n
\
parent a1b6decaaac768b5e01e1b5dbf5b2cc081bed1eb
\n
\
author Some User <someuser@gmail.com> 1454537944 -0700
\n
\
committer Some User <someuser@gmail.com> 1454537944 -0700
\n
\
\n
\
corrupt signature
\n
"
;
cl_git_pass
(
git_repository_odb__weakptr
(
&
odb
,
g_repo
));
cl_git_pass
(
git_odb_write
(
&
commit_id
,
odb
,
passing_commit_cases
[
4
],
strlen
(
passing_commit_cases
[
4
]),
GIT_OBJ_COMMIT
));
...
...
@@ -523,6 +538,15 @@ a simple commit which works\n";
cl_git_fail_with
(
GIT_ENOTFOUND
,
git_commit_extract_signature
(
&
signature
,
&
signed_data
,
g_repo
,
&
commit_id
,
NULL
));
cl_assert_equal_i
(
GITERR_OBJECT
,
giterr_last
()
->
klass
);
/* Parse the commit with a single-line signature */
git_buf_clear
(
&
signature
);
git_buf_clear
(
&
signed_data
);
cl_git_pass
(
git_odb_write
(
&
commit_id
,
odb
,
oneline_signature
,
strlen
(
oneline_signature
),
GIT_OBJ_COMMIT
));
cl_git_pass
(
git_commit_extract_signature
(
&
signature
,
&
signed_data
,
g_repo
,
&
commit_id
,
NULL
));
cl_assert_equal_s
(
"bad"
,
signature
.
ptr
);
cl_assert_equal_s
(
oneline_data
,
signed_data
.
ptr
);
git_buf_free
(
&
signature
);
git_buf_free
(
&
signed_data
);
...
...
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