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
6c0d5366
Commit
6c0d5366
authored
Oct 22, 2021
by
Yoichi Nakayama
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cause error when date parsing is failed
parent
776a6a8e
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
2 deletions
+24
-2
src/date.c
+1
-1
src/revparse.c
+3
-1
tests/date/date.c
+7
-0
tests/refs/revparse.c
+13
-0
No files found.
src/date.c
View file @
6c0d5366
...
...
@@ -853,7 +853,7 @@ static git_time_t approxidate_str(const char *date,
}
pending_number
(
&
tm
,
&
number
);
if
(
!
touched
)
*
error_ret
=
1
;
*
error_ret
=
-
1
;
return
update_tm
(
&
tm
,
&
now
,
0
);
}
...
...
src/revparse.c
View file @
6c0d5366
...
...
@@ -348,8 +348,10 @@ static int handle_at_syntax(git_object **out, git_reference **ref, const char *s
goto
cleanup
;
}
if
(
git__date_parse
(
&
timestamp
,
curly_braces_content
)
<
0
)
if
(
git__date_parse
(
&
timestamp
,
curly_braces_content
)
<
0
)
{
error
=
GIT_EINVALIDSPEC
;
goto
cleanup
;
}
error
=
retrieve_revobject_from_reflog
(
out
,
ref
,
repo
,
git_str_cstr
(
&
identifier
),
(
size_t
)
timestamp
);
...
...
tests/date/date.c
View file @
6c0d5366
...
...
@@ -13,3 +13,10 @@ void test_date_date__overflow(void)
cl_assert
(
d2038
<
d2039
);
#endif
}
void
test_date_date__invalid_date
(
void
)
{
git_time_t
d
;
cl_git_fail
(
git__date_parse
(
&
d
,
""
));
cl_git_fail
(
git__date_parse
(
&
d
,
"NEITHER_INTEGER_NOR_DATETIME"
));
}
tests/refs/revparse.c
View file @
6c0d5366
...
...
@@ -460,6 +460,19 @@ void test_refs_revparse__date(void)
test_object
(
"with-empty-log@{2 days ago}"
,
NULL
);
}
void
test_refs_revparse__invalid_date
(
void
)
{
/*
* $ git rev-parse HEAD@{} --
* fatal: bad revision 'HEAD@{}'
*
* $ git rev-parse HEAD@{NEITHER_INTEGER_NOR_DATETIME} --
* fatal: bad revision 'HEAD@{NEITHER_INTEGER_NOR_DATETIME}'
*/
test_object
(
"HEAD@{}"
,
NULL
);
test_object
(
"HEAD@{NEITHER_INTEGER_NOR_DATETIME}"
,
NULL
);
}
void
test_refs_revparse__colon
(
void
)
{
assert_invalid_single_spec
(
":/"
);
...
...
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