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
5274c31a
Commit
5274c31a
authored
Aug 03, 2011
by
schu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
signature.c: fix off-by-one error
Signed-off-by: schu <schu-github@schulog.org>
parent
03d88ed4
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
1 deletions
+29
-1
src/signature.c
+1
-1
tests/t04-commit.c
+28
-0
No files found.
src/signature.c
View file @
5274c31a
...
...
@@ -62,7 +62,7 @@ static int process_trimming(const char *input, char **storage, const char *input
left
=
skip_leading_spaces
(
input
,
input_end
);
right
=
skip_trailing_spaces
(
input
,
input_end
-
1
);
if
(
right
<
=
left
)
{
if
(
right
<
left
)
{
if
(
fail_when_empty
)
return
git__throw
(
GIT_EINVALIDARGS
,
"Failed to trim. Input is either empty or only contains spaces"
);
else
...
...
tests/t04-commit.c
View file @
5274c31a
...
...
@@ -478,6 +478,31 @@ BEGIN_TEST(signature1, "can not create a signature with empty name or email")
must_fail
(
try_build_signature
(
"nulltoken"
,
" "
,
1234567890
,
60
));
END_TEST
BEGIN_TEST
(
signature2
,
"creating a one character signature"
)
git_signature
*
sign
;
sign
=
git_signature_new
(
"x"
,
"foo@bar.baz"
,
1234567890
,
60
);
must_be_true
(
sign
!=
NULL
);
must_pass
(
strcmp
(
sign
->
name
,
"x"
));
must_pass
(
strcmp
(
sign
->
email
,
"foo@bar.baz"
));
git_signature_free
((
git_signature
*
)
sign
);
END_TEST
BEGIN_TEST
(
signature3
,
"creating a two character signature"
)
git_signature
*
sign
;
sign
=
git_signature_new
(
"xx"
,
"x@y.z"
,
1234567890
,
60
);
must_be_true
(
sign
!=
NULL
);
must_pass
(
strcmp
(
sign
->
name
,
"x"
));
must_pass
(
strcmp
(
sign
->
email
,
"foo@bar.baz"
));
git_signature_free
((
git_signature
*
)
sign
);
END_TEST
BEGIN_TEST
(
signature4
,
"creating a zero character signature"
)
git_signature
*
sign
;
sign
=
git_signature_new
(
""
,
"x@y.z"
,
1234567890
,
60
);
must_be_true
(
sign
==
NULL
);
END_TEST
/* External declaration for testing the buffer parsing method */
int
commit_parse_buffer
(
git_commit
*
commit
,
void
*
data
,
size_t
len
,
unsigned
int
parse_flags
);
...
...
@@ -758,4 +783,7 @@ BEGIN_SUITE(commit)
ADD_TEST
(
signature0
);
ADD_TEST
(
signature1
);
ADD_TEST
(
signature2
);
ADD_TEST
(
signature3
);
ADD_TEST
(
signature4
);
END_SUITE
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