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
118cf57d
Commit
118cf57d
authored
Jul 04, 2012
by
nulltoken
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
revwalk: relax the parsing of the commit time
parent
5b071115
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
7 deletions
+68
-7
src/revwalk.c
+24
-7
tests-clar/revwalk/signatureparsing.c
+44
-0
No files found.
src/revwalk.c
View file @
118cf57d
...
...
@@ -188,7 +188,7 @@ static int commit_quick_parse(git_revwalk *walk, commit_object *commit, git_rawo
const
size_t
parent_len
=
strlen
(
"parent "
)
+
GIT_OID_HEXSZ
+
1
;
unsigned
char
*
buffer
=
raw
->
data
;
unsigned
char
*
buffer_end
=
buffer
+
raw
->
len
;
unsigned
char
*
parents_start
;
unsigned
char
*
parents_start
,
*
committer_start
;
int
i
,
parents
=
0
;
int
commit_time
;
...
...
@@ -219,17 +219,34 @@ static int commit_quick_parse(git_revwalk *walk, commit_object *commit, git_rawo
commit
->
out_degree
=
(
unsigned
short
)
parents
;
if
((
committer_start
=
buffer
=
memchr
(
buffer
,
'\n'
,
buffer_end
-
buffer
))
==
NULL
)
return
commit_error
(
commit
,
"object is corrupted"
);
buffer
++
;
if
((
buffer
=
memchr
(
buffer
,
'\n'
,
buffer_end
-
buffer
))
==
NULL
)
return
commit_error
(
commit
,
"object is corrupted"
);
if
((
buffer
=
memchr
(
buffer
,
'<'
,
buffer_end
-
buffer
))
==
NULL
||
(
buffer
=
memchr
(
buffer
,
'>'
,
buffer_end
-
buffer
))
==
NULL
)
return
commit_error
(
commit
,
"malformed author information"
);
/* Skip trailing spaces */
while
(
buffer
>
committer_start
&&
git__isspace
(
*
buffer
))
buffer
--
;
/* Seek for the begining of the pack of digits */
while
(
buffer
>
committer_start
&&
git__isdigit
(
*
buffer
))
buffer
--
;
while
(
*
buffer
==
'>'
||
git__isspace
(
*
buffer
))
buffer
++
;
/* Skip potential timezone offset */
if
((
buffer
>
committer_start
)
&&
(
*
buffer
==
'+'
||
*
buffer
==
'-'
))
{
buffer
--
;
while
(
buffer
>
committer_start
&&
git__isspace
(
*
buffer
))
buffer
--
;
while
(
buffer
>
committer_start
&&
git__isdigit
(
*
buffer
))
buffer
--
;
}
if
(
git__strtol32
(
&
commit_time
,
(
char
*
)
buffer
,
NULL
,
10
)
<
0
)
if
(
(
buffer
==
committer_start
)
||
(
git__strtol32
(
&
commit_time
,
(
char
*
)(
buffer
+
1
),
NULL
,
10
)
<
0
)
)
return
commit_error
(
commit
,
"cannot parse commit time"
);
commit
->
time
=
(
time_t
)
commit_time
;
...
...
tests-clar/revwalk/signatureparsing.c
0 → 100644
View file @
118cf57d
#include "clar_libgit2.h"
static
git_repository
*
_repo
;
static
git_revwalk
*
_walk
;
void
test_revwalk_signatureparsing__initialize
(
void
)
{
cl_git_pass
(
git_repository_open
(
&
_repo
,
cl_fixture
(
"testrepo.git"
)));
cl_git_pass
(
git_revwalk_new
(
&
_walk
,
_repo
));
}
void
test_revwalk_signatureparsing__cleanup
(
void
)
{
git_revwalk_free
(
_walk
);
git_repository_free
(
_repo
);
}
void
test_revwalk_signatureparsing__do_not_choke_when_name_contains_angle_brackets
(
void
)
{
git_reference
*
ref
;
git_oid
commit_oid
;
git_commit
*
commit
;
const
git_signature
*
signature
;
/*
* The branch below points at a commit with angle brackets in the committer/author name
* committer <Yu V. Bin Haacked> <foo@example.com> 1323847743 +0100
*/
cl_git_pass
(
git_reference_lookup
(
&
ref
,
_repo
,
"refs/heads/haacked"
));
git_revwalk_push
(
_walk
,
git_reference_oid
(
ref
));
cl_git_pass
(
git_revwalk_next
(
&
commit_oid
,
_walk
));
cl_git_pass
(
git_commit_lookup
(
&
commit
,
_repo
,
git_reference_oid
(
ref
)));
signature
=
git_commit_committer
(
commit
);
cl_assert_equal_s
(
"Yu V. Bin Haacked"
,
signature
->
email
);
cl_assert_equal_s
(
""
,
signature
->
name
);
cl_assert_equal_i
(
1323847743
,
(
int
)
signature
->
when
.
time
);
cl_assert_equal_i
(
60
,
signature
->
when
.
offset
);
git_commit_free
(
commit
);
git_reference_free
(
ref
);
}
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