From: Junio C Hamano <gitster@pobox.com>
To: Denton Liu <liu.denton@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH] refs: allow @{n} to work with n-sized reflog
Date: Wed, 06 Jan 2021 13:02:05 -0800 [thread overview]
Message-ID: <xmqqft3drd82.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <X/V0DU+CD6mS36dK@generichostname> (Denton Liu's message of "Wed, 6 Jan 2021 00:25:49 -0800")
Denton Liu <liu.denton@gmail.com> writes:
>> > - if (timestamp <= cb->at_time || cb->cnt == 0) {
>> > + if (cb->cnt > 0)
>> > + cb->cnt--;
>> > + at_indexed_ent = cb->cnt == 0 && !is_null_oid(ooid);
>>
>> The code treats two cases identically (i.e. the case where cb->cnt
>> was originally zero, and one). Is that intended?
>
> It shouldn't be possible for cb->cnt == 0 on the first iteration
> because there's a special-case check at [0]. As a result, it can only be
> -1 or >= 1 on the first iteration.
>
> The -1 case happens when we're doing date-based lookup and that's what
> this if is intended to handle.
I knew about -1; it wasn't apparent that the caller won't call us
with cnt==0. Perhaps it deserves a mention in an in-code comment.
> "at_indexed_ent" is meant to signal when we are indexing the reflog
> numerically (as opposed to by date), we have arrived at the correct
> entry. If you have a more fitting name, I'm open to suggestions.
When querying for <ref>@{24}, all the entries are indexed
numerically (counted), not just the 24th one, and that contributed
to my puzzlement.
I offhand do not think of a "name", but "at target", "found",
"reached count", are phrases that come to my mind as starting
points.
Thanks.
next prev parent reply other threads:[~2021-01-06 21:02 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-02 1:36 [PATCH] refs: allow @{n} to work with n-sized reflog Denton Liu
2021-01-02 22:30 ` Martin Ågren
2021-01-03 1:24 ` Denton Liu
2021-01-05 8:52 ` SZEDER Gábor
2021-01-06 5:55 ` Junio C Hamano
2021-01-06 8:25 ` Denton Liu
2021-01-06 21:02 ` Junio C Hamano [this message]
2021-01-06 9:01 ` [PATCH v2 0/2] " Denton Liu
2021-01-06 9:01 ` [PATCH v2 1/2] refs: factor out set_read_ref_cutoffs() Denton Liu
2021-01-06 9:01 ` [PATCH v2 2/2] refs: allow @{n} to work with n-sized reflog Denton Liu
2021-01-06 9:59 ` SZEDER Gábor
2021-01-07 10:36 ` [PATCH v3 0/2] " Denton Liu
2021-01-07 10:36 ` [PATCH v3 1/2] refs: factor out set_read_ref_cutoffs() Denton Liu
2021-01-07 10:36 ` [PATCH v3 2/2] refs: allow @{n} to work with n-sized reflog Denton Liu
2021-01-10 20:31 ` Simon Ruderich
2021-01-12 6:14 ` [PATCH v3] fixup! " Denton Liu
2021-01-12 6:18 ` Denton Liu
2021-01-12 6:27 ` Junio C Hamano
2021-01-10 14:44 ` [PATCH v3 0/2] " SZEDER Gábor
2021-01-10 20:24 ` Junio C Hamano
2021-01-07 10:43 ` [PATCH v3 3/2] fixup! " Denton Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqft3drd82.fsf@gitster.c.googlers.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=liu.denton@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).