diff options
author | Junio C Hamano <gitster@pobox.com> | 2024-03-05 09:44:42 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-03-05 09:44:42 -0800 |
commit | 74522bbd98418bf94e918cef2cf911402eca692f (patch) | |
tree | dfe7e57ac15749074e68e24972d048b8ca47e3c0 /object-name.c | |
parent | 542d093b1d3411456603c9a539ab67b154e6f77f (diff) | |
parent | 5edd12672086c6b6d92147925dda5dd3bca2b658 (diff) |
Merge branch 'jk/reflog-special-cases-fix'
The logic to access reflog entries by date and number had ugly
corner cases at the boundaries, which have been cleaned up.
* jk/reflog-special-cases-fix:
read_ref_at(): special-case ref@{0} for an empty reflog
get_oid_basic(): special-case ref@{n} for oldest reflog entry
Revert "refs: allow @{n} to work with n-sized reflog"
Diffstat (limited to 'object-name.c')
-rw-r--r-- | object-name.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/object-name.c b/object-name.c index 3a2ef5d680..511f09bc0f 100644 --- a/object-name.c +++ b/object-name.c @@ -1034,6 +1034,15 @@ static int get_oid_basic(struct repository *r, const char *str, int len, len, str, show_date(co_time, co_tz, DATE_MODE(RFC2822))); } + } else if (nth == co_cnt && !is_null_oid(oid)) { + /* + * We were asked for the Nth reflog (counting + * from 0), but there were only N entries. + * read_ref_at() will have returned "1" to tell + * us it did not find an entry, but it did + * still fill in the oid with the "old" value, + * which we can use. + */ } else { if (flags & GET_OID_QUIETLY) { exit(128); |