Re: [PATCH 3/3] read_ref_at(): special-case ref@{0} for an empty reflog
From: Jeff King <hidden>
Date: 2024-02-27 08:07:34
On Mon, Feb 26, 2024 at 09:25:32AM -0800, Junio C Hamano wrote:
Jeff King [off-list ref] writes:quoted
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