diff options
| author | Edward Thomson <ethomson@edwardthomson.com> | 2021-12-23 14:09:09 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-23 14:09:09 -0500 |
| commit | ab5b3f37f5e74805250685a08fa9f4220e5dba12 (patch) | |
| tree | 9be0bddcf37b3ed9e869e8f349a6fcf55276cf17 /src | |
| parent | 4b27009cadb1bf09ad272f72745310a881762d78 (diff) | |
| parent | 7bb206a76dca70b7db236315d348c6c9fc325cab (diff) | |
| download | libgit2-ab5b3f37f5e74805250685a08fa9f4220e5dba12.tar.gz | |
Merge pull request #6095 from yoichi/better-compatiblity-for-at-time-notation
Better revparse compatibility for at time notation
Diffstat (limited to 'src')
| -rw-r--r-- | src/date.c | 4 | ||||
| -rw-r--r-- | src/revparse.c | 17 |
2 files changed, 15 insertions, 6 deletions
diff --git a/src/date.c b/src/date.c index 1529276e2..0e5ffc96b 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(git_str *out, git_time_t time, int offset) diff --git a/src/revparse.c b/src/revparse.c index 52dd0720b..5d3ff77ed 100644 --- a/src/revparse.c +++ b/src/revparse.c @@ -208,7 +208,7 @@ static int retrieve_oid_from_reflog(git_oid *oid, git_reference *ref, size_t ide { git_reflog *reflog; size_t numentries; - const git_reflog_entry *entry; + const git_reflog_entry *entry = NULL; bool search_by_pos = (identifier <= 100000000); if (git_reflog_read(&reflog, git_reference_owner(ref), git_reference_name(ref)) < 0) @@ -237,8 +237,15 @@ static int retrieve_oid_from_reflog(git_oid *oid, git_reference *ref, size_t ide break; } - if (i == numentries) - goto notfound; + if (i == numentries) { + if (entry == NULL) + goto notfound; + + /* + * TODO: emit a warning (log for 'branch' only goes back to ...) + */ + git_oid_cpy(oid, git_reflog_entry_id_new(entry)); + } } git_reflog_free(reflog); @@ -345,8 +352,10 @@ static int handle_at_syntax(git_object **out, git_reference **ref, const char *s goto cleanup; } - if (git_date_parse(×tamp, curly_braces_content) < 0) + if (git_date_parse(×tamp, curly_braces_content) < 0) { + error = GIT_EINVALIDSPEC; goto cleanup; + } error = retrieve_revobject_from_reflog(out, ref, repo, git_str_cstr(&identifier), (size_t)timestamp); |
