diff options
| author | Yoichi Nakayama <yoichi.nakayama@gmail.com> | 2021-10-22 00:09:39 +0900 |
|---|---|---|
| committer | Yoichi Nakayama <yoichi.nakayama@gmail.com> | 2021-10-22 00:09:39 +0900 |
| commit | 776a6a8e5f8e258d31aded73c0ce38df6ac7bdc4 (patch) | |
| tree | 91ae8845d413ed845fe52a7261468e47ecebba49 /src | |
| parent | 49ebc8a7551c32b3ea67d7d191b20be3e8905a8f (diff) | |
| download | libgit2-776a6a8e5f8e258d31aded73c0ce38df6ac7bdc4.tar.gz | |
Return the oldest reflog entry on revparse when older time is given
For better compatibility with git command which returns the oldest
log entry with a warning message.
Diffstat (limited to 'src')
| -rw-r--r-- | src/revparse.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/revparse.c b/src/revparse.c index cf39936a5..8be22d6dd 100644 --- a/src/revparse.c +++ b/src/revparse.c @@ -207,7 +207,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) @@ -236,8 +236,12 @@ 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; + + git_oid_cpy(oid, git_reflog_entry_id_new(entry)); + } } git_reflog_free(reflog); |
