summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYoichi Nakayama <yoichi.nakayama@gmail.com>2021-10-22 07:54:12 +0900
committerYoichi Nakayama <yoichi.nakayama@gmail.com>2021-10-22 07:54:12 +0900
commit6c0d5366d9a9d24c76c1ca444a592111a1b2bdc3 (patch)
treef460158fa1829d0d9ef8747380dccb22c2d51ed0 /src
parent776a6a8e5f8e258d31aded73c0ce38df6ac7bdc4 (diff)
downloadlibgit2-6c0d5366d9a9d24c76c1ca444a592111a1b2bdc3.tar.gz
Cause error when date parsing is failed
Diffstat (limited to 'src')
-rw-r--r--src/date.c4
-rw-r--r--src/revparse.c4
2 files changed, 5 insertions, 3 deletions
diff --git a/src/date.c b/src/date.c
index 2297ee66c..af6694e30 100644
--- a/src/date.c
+++ b/src/date.c
@@ -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);
}
@@ -872,7 +872,7 @@ int git__date_parse(git_time_t *out, const char *date)
return -1;
*out = approxidate_str(date, time_sec, &error_ret);
- return error_ret;
+ return error_ret;
}
int git__date_rfc2822_fmt(char *out, size_t len, const git_time *date)
diff --git a/src/revparse.c b/src/revparse.c
index 8be22d6dd..2815bcfc4 100644
--- a/src/revparse.c
+++ b/src/revparse.c
@@ -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);