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
855f048a
Commit
855f048a
authored
Oct 21, 2015
by
Vicent Marti
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3478 from libgit2/vmg/crud
signature: Strip crud
parents
4280fabb
bbe1957b
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
30 additions
and
8 deletions
+30
-8
src/index.c
+3
-3
src/signature.c
+16
-2
tests/commit/signature.c
+7
-0
tests/diff/workdir.c
+1
-1
tests/revwalk/basic.c
+2
-1
tests/revwalk/signatureparsing.c
+1
-1
No files found.
src/index.c
View file @
855f048a
...
@@ -1193,13 +1193,13 @@ static int index_no_dups(void **old, void *new)
...
@@ -1193,13 +1193,13 @@ static int index_no_dups(void **old, void *new)
}
}
static
void
index_existing_and_best
(
static
void
index_existing_and_best
(
const
git_index_entry
**
existing
,
git_index_entry
**
existing
,
size_t
*
existing_position
,
size_t
*
existing_position
,
const
git_index_entry
**
best
,
git_index_entry
**
best
,
git_index
*
index
,
git_index
*
index
,
const
git_index_entry
*
entry
)
const
git_index_entry
*
entry
)
{
{
const
git_index_entry
*
e
;
git_index_entry
*
e
;
size_t
pos
;
size_t
pos
;
int
error
;
int
error
;
...
...
src/signature.c
View file @
855f048a
...
@@ -34,13 +34,27 @@ static bool contains_angle_brackets(const char *input)
...
@@ -34,13 +34,27 @@ static bool contains_angle_brackets(const char *input)
return
strchr
(
input
,
'<'
)
!=
NULL
||
strchr
(
input
,
'>'
)
!=
NULL
;
return
strchr
(
input
,
'<'
)
!=
NULL
||
strchr
(
input
,
'>'
)
!=
NULL
;
}
}
static
bool
is_crud
(
unsigned
char
c
)
{
return
c
<=
32
||
c
==
'.'
||
c
==
','
||
c
==
':'
||
c
==
';'
||
c
==
'<'
||
c
==
'>'
||
c
==
'"'
||
c
==
'\\'
||
c
==
'\''
;
}
static
char
*
extract_trimmed
(
const
char
*
ptr
,
size_t
len
)
static
char
*
extract_trimmed
(
const
char
*
ptr
,
size_t
len
)
{
{
while
(
len
&&
git__isspace
(
ptr
[
0
]))
{
while
(
len
&&
is_crud
((
unsigned
char
)
ptr
[
0
]))
{
ptr
++
;
len
--
;
ptr
++
;
len
--
;
}
}
while
(
len
&&
git__isspace
(
ptr
[
len
-
1
]))
{
while
(
len
&&
is_crud
((
unsigned
char
)
ptr
[
len
-
1
]))
{
len
--
;
len
--
;
}
}
...
...
tests/commit/signature.c
View file @
855f048a
...
@@ -35,6 +35,13 @@ void test_commit_signature__leading_and_trailing_spaces_are_trimmed(void)
...
@@ -35,6 +35,13 @@ void test_commit_signature__leading_and_trailing_spaces_are_trimmed(void)
assert_name_and_email
(
"nulltoken"
,
"emeric.fermas@gmail.com"
,
"
\t
nulltoken
\n
"
,
"
\n
emeric.fermas@gmail.com
\n
"
);
assert_name_and_email
(
"nulltoken"
,
"emeric.fermas@gmail.com"
,
"
\t
nulltoken
\n
"
,
"
\n
emeric.fermas@gmail.com
\n
"
);
}
}
void
test_commit_signature__leading_and_trailing_crud_is_trimmed
(
void
)
{
assert_name_and_email
(
"nulltoken"
,
"emeric.fermas@gmail.com"
,
"
\"
nulltoken
\"
"
,
"
\"
emeric.fermas@gmail.com
\"
"
);
assert_name_and_email
(
"nulltoken w"
,
"emeric.fermas@gmail.com"
,
"nulltoken w."
,
"emeric.fermas@gmail.com"
);
assert_name_and_email
(
"nulltoken
\xe2\x98\xba
"
,
"emeric.fermas@gmail.com"
,
"nulltoken
\xe2\x98\xba
"
,
"emeric.fermas@gmail.com"
);
}
void
test_commit_signature__angle_brackets_in_names_are_not_supported
(
void
)
void
test_commit_signature__angle_brackets_in_names_are_not_supported
(
void
)
{
{
cl_git_fail
(
try_build_signature
(
"<Phil Haack"
,
"phil@haack"
,
1234567890
,
60
));
cl_git_fail
(
try_build_signature
(
"<Phil Haack"
,
"phil@haack"
,
1234567890
,
60
));
...
...
tests/diff/workdir.c
View file @
855f048a
...
@@ -2080,7 +2080,7 @@ void test_diff_workdir__to_index_pathlist(void)
...
@@ -2080,7 +2080,7 @@ void test_diff_workdir__to_index_pathlist(void)
cl_git_pass
(
git_repository_index
(
&
index
,
g_repo
));
cl_git_pass
(
git_repository_index
(
&
index
,
g_repo
));
opts
.
flags
=
GIT_DIFF_INCLUDE_IGNORED
;
opts
.
flags
=
GIT_DIFF_INCLUDE_IGNORED
;
opts
.
pathspec
.
strings
=
pathlist
.
contents
;
opts
.
pathspec
.
strings
=
(
char
**
)
pathlist
.
contents
;
opts
.
pathspec
.
count
=
pathlist
.
length
;
opts
.
pathspec
.
count
=
pathlist
.
length
;
cl_git_pass
(
git_diff_index_to_workdir
(
&
diff
,
g_repo
,
index
,
&
opts
));
cl_git_pass
(
git_diff_index_to_workdir
(
&
diff
,
g_repo
,
index
,
&
opts
));
...
...
tests/revwalk/basic.c
View file @
855f048a
...
@@ -456,7 +456,8 @@ void test_revwalk_basic__big_timestamp(void)
...
@@ -456,7 +456,8 @@ void test_revwalk_basic__big_timestamp(void)
cl_git_pass
(
git_signature_new
(
&
sig
,
"Joe"
,
"joe@example.com"
,
2399662595
,
0
));
cl_git_pass
(
git_signature_new
(
&
sig
,
"Joe"
,
"joe@example.com"
,
2399662595
,
0
));
cl_git_pass
(
git_commit_tree
(
&
tree
,
tip
));
cl_git_pass
(
git_commit_tree
(
&
tree
,
tip
));
cl_git_pass
(
git_commit_create
(
&
id
,
_repo
,
"HEAD"
,
sig
,
sig
,
NULL
,
"some message"
,
tree
,
1
,
&
tip
));
cl_git_pass
(
git_commit_create
(
&
id
,
_repo
,
"HEAD"
,
sig
,
sig
,
NULL
,
"some message"
,
tree
,
1
,
(
const
git_commit
**
)
&
tip
));
cl_git_pass
(
git_revwalk_push_head
(
_walk
));
cl_git_pass
(
git_revwalk_push_head
(
_walk
));
...
...
tests/revwalk/signatureparsing.c
View file @
855f048a
...
@@ -38,7 +38,7 @@ void test_revwalk_signatureparsing__do_not_choke_when_name_contains_angle_bracke
...
@@ -38,7 +38,7 @@ void test_revwalk_signatureparsing__do_not_choke_when_name_contains_angle_bracke
signature
=
git_commit_committer
(
commit
);
signature
=
git_commit_committer
(
commit
);
cl_assert_equal_s
(
"foo@example.com"
,
signature
->
email
);
cl_assert_equal_s
(
"foo@example.com"
,
signature
->
email
);
cl_assert_equal_s
(
"
<Yu V. Bin Haacked>
"
,
signature
->
name
);
cl_assert_equal_s
(
"
Yu V. Bin Haacked
"
,
signature
->
name
);
cl_assert_equal_i
(
1323847743
,
(
int
)
signature
->
when
.
time
);
cl_assert_equal_i
(
1323847743
,
(
int
)
signature
->
when
.
time
);
cl_assert_equal_i
(
60
,
signature
->
when
.
offset
);
cl_assert_equal_i
(
60
,
signature
->
when
.
offset
);
...
...
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