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 /refs.h | |
parent | 542d093b1d3411456603c9a539ab67b154e6f77f (diff) | |
parent | 5edd12672086c6b6d92147925dda5dd3bca2b658 (diff) | |
download | git-74522bbd98418bf94e918cef2cf911402eca692f.tar.gz |
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 'refs.h')
-rw-r--r-- | refs.h | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -440,7 +440,20 @@ int refs_create_reflog(struct ref_store *refs, const char *refname, struct strbuf *err); int safe_create_reflog(const char *refname, struct strbuf *err); -/** Reads log for the value of ref during at_time. **/ +/** + * Reads log for the value of ref during at_time (in which case "cnt" should be + * negative) or the reflog "cnt" entries from the top (in which case "at_time" + * should be 0). + * + * If we found the reflog entry in question, returns 0 (and details of the + * entry can be found in the out-parameters). + * + * If we ran out of reflog entries, the out-parameters are filled with the + * details of the oldest entry we did find, and the function returns 1. Note + * that there is one important special case here! If the reflog was empty + * and the caller asked for the 0-th cnt, we will return "1" but leave the + * "oid" field untouched. + **/ int read_ref_at(struct ref_store *refs, const char *refname, unsigned int flags, timestamp_t at_time, int cnt, |