Re: [PATCH 3/3] read_ref_at(): special-case ref@{0} for an empty reflog
- From
Jeff King <peff@peff.net>
- Date
- Feb 27, 2024, 08:07 UTC
- Message-ID
- <20240227080732.GG3263678@coredump.intra.peff.net>
- In-Reply-To
- <xmqqh6hvcf3n.fsf@gitster.g>
On Mon, Feb 26, 2024 at 09:25:32AM -0800, Junio C Hamano wrote:
Show 12 quoted lines
> Jeff King <peff@peff.net> writes:
>
> > That's one of the reasons I split this out from patch 2; we can see
> > exactly what must be done to make each case work. And in fact I had
> > originally started to write a patch that simply changed t1508 to expect
> > failure. I could still be persuaded to go that way if anybody feels
> > strongly.
>
> I do not feel strongly either way myself. It just is interesting
> that the older end of the history is with @{20.years.ago} special
> case that is only for time-based query, while the newer end of the
> history is with @{0} special case.I laid out my thinking on the 20.years.ago special case in another reply, but I wanted to say one more thing. The special case here in patch 3 is making @{0} work for the empty reflog, but there is no matching special case for time-based timestamps. If you have an empty reflog and ask for @{20.years.ago}, you will get the usual "nope, the reflog is empty" response (as opposed to having a non-empty reflog that cuts off before 20 years ago).
Obviously we could make that work, but I think the point is that "@{0}" is special magic for "the current value" in a way that a timestamp isn't really.
-Peff