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
f98131be
Commit
f98131be
authored
Jun 17, 2018
by
Nika Layzell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Require the length argument to git_mailmap_from_buffer and make mailmap_add_buffer internal
parent
9faf36a6
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
27 deletions
+9
-27
include/git2/mailmap.h
+1
-17
src/mailmap.c
+4
-8
tests/mailmap/basic.c
+2
-1
tests/mailmap/parsing.c
+2
-1
No files found.
include/git2/mailmap.h
View file @
f98131be
...
...
@@ -54,27 +54,11 @@ GIT_EXTERN(int) git_mailmap_add_entry(
const
char
*
replace_name
,
const
char
*
replace_email
);
/**
* Parse mailmap entries from a buffer.
*
* @param mm mailmap to add the entries to
* @param buf the buffer to read the mailmap file from
* @param len the length of the input buffer [optional: 0 defaults to 'strlen']
* @return 0 on success, or an error code
*/
GIT_EXTERN
(
int
)
git_mailmap_add_buffer
(
git_mailmap
*
mm
,
const
char
*
buf
,
size_t
len
);
/**
* Create a new mailmap instance containing a single mailmap file
*
* This method is a simple utility wrapper for the following sequence
* of calls:
* - git_mailmap_new
* - git_mailmap_add_buffer
*
* @param out pointer to store the new mailmap
* @param buf buffer to parse the mailmap from
* @param len the length of the input buffer
[optional: 0 defaults to 'strlen']
* @param len the length of the input buffer
* @return 0 on success, or an error code
*/
GIT_EXTERN
(
int
)
git_mailmap_from_buffer
(
...
...
src/mailmap.c
View file @
f98131be
...
...
@@ -223,7 +223,7 @@ int git_mailmap_add_entry(
replace_email
,
strlen
(
replace_email
));
}
int
git_
mailmap_add_buffer
(
git_mailmap
*
mm
,
const
char
*
buf
,
size_t
len
)
static
int
mailmap_add_buffer
(
git_mailmap
*
mm
,
const
char
*
buf
,
size_t
len
)
{
int
error
;
git_parse_ctx
ctx
;
...
...
@@ -234,10 +234,6 @@ int git_mailmap_add_buffer(git_mailmap *mm, const char *buf, size_t len)
git_buf
replace_name
=
GIT_BUF_INIT
;
git_buf
replace_email
=
GIT_BUF_INIT
;
/* If `len` is passed as 0, use strlen to get the real length */
if
(
buf
&&
len
==
0
)
len
=
strlen
(
buf
);
/* Buffers may not contain '\0's. */
if
(
memchr
(
buf
,
'\0'
,
len
)
!=
NULL
)
return
-
1
;
...
...
@@ -278,7 +274,7 @@ int git_mailmap_from_buffer(git_mailmap **out, const char *data, size_t len)
if
(
error
<
0
)
return
error
;
error
=
git_
mailmap_add_buffer
(
*
out
,
data
,
len
);
error
=
mailmap_add_buffer
(
*
out
,
data
,
len
);
if
(
error
<
0
)
{
git_mailmap_free
(
*
out
);
*
out
=
NULL
;
...
...
@@ -308,7 +304,7 @@ static int mailmap_add_blob(
if
(
error
<
0
)
goto
cleanup
;
error
=
git_
mailmap_add_buffer
(
mm
,
content
.
ptr
,
content
.
size
);
error
=
mailmap_add_buffer
(
mm
,
content
.
ptr
,
content
.
size
);
if
(
error
<
0
)
goto
cleanup
;
...
...
@@ -335,7 +331,7 @@ static int mailmap_add_file_ondisk(
if
(
error
<
0
)
goto
cleanup
;
error
=
git_
mailmap_add_buffer
(
mm
,
content
.
ptr
,
content
.
size
);
error
=
mailmap_add_buffer
(
mm
,
content
.
ptr
,
content
.
size
);
if
(
error
<
0
)
goto
cleanup
;
...
...
tests/mailmap/basic.c
View file @
f98131be
...
...
@@ -27,7 +27,8 @@ struct {
void
test_mailmap_basic__initialize
(
void
)
{
cl_git_pass
(
git_mailmap_from_buffer
(
&
mailmap
,
TEST_MAILMAP
,
0
));
cl_git_pass
(
git_mailmap_from_buffer
(
&
mailmap
,
TEST_MAILMAP
,
strlen
(
TEST_MAILMAP
)));
}
void
test_mailmap_basic__cleanup
(
void
)
...
...
tests/mailmap/parsing.c
View file @
f98131be
...
...
@@ -67,7 +67,8 @@ static const mailmap_entry resolved_untracked[] = {
void
test_mailmap_parsing__string
(
void
)
{
cl_git_pass
(
git_mailmap_from_buffer
(
&
g_mailmap
,
string_mailmap
,
0
));
cl_git_pass
(
git_mailmap_from_buffer
(
&
g_mailmap
,
string_mailmap
,
strlen
(
string_mailmap
)));
/* We should have parsed all of the entries */
check_mailmap_entries
(
g_mailmap
,
entries
,
ARRAY_SIZE
(
entries
));
...
...
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