git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
Previous: Junio C HamanoNext: Junio C Hamano
Message 16 of 27 in “Segfault: git show-branch --reflog refs/pullreqs/1”
  1. Yasushi SHOJIFeb 21, 2024
  2. Jeff KingFeb 21, 2024
  3. Patrick SteinhardtFeb 21, 2024
  4. Jeff KingFeb 21, 2024
  5. Junio C HamanoFeb 21, 2024
  6. Patrick SteinhardtFeb 22, 2024
  7. Junio C HamanoFeb 22, 2024
  8. Jeff KingFeb 22, 2024
  9. 0/3 show-branch --reflog fixesJeff King, Feb 26, 2024
  10. 1/3 Revert "refs: allow @{n} to work with n-sized reflog"Jeff King, Feb 26, 2024
  11. 2/3 get_oid_basic(): special-case ref@{n} for oldest reflog entryJeff King, Feb 26, 2024
  12. Junio C HamanoFeb 26, 2024
  13. 3/3 read_ref_at(): special-case ref@{0} for an empty reflogJeff King, Feb 26, 2024
  14. Jeff KingFeb 26, 2024
  15. Junio C HamanoFeb 26, 2024
  16. Jeff KingFeb 27, 2024
  17. Junio C HamanoFeb 26, 2024
  18. Jeff KingFeb 27, 2024
  19. Junio C HamanoFeb 27, 2024
  20. Patrick SteinhardtFeb 21, 2024
  21. 0/2 Detect empty or missing reflogs with `ref@{0}`Patrick Steinhardt, Feb 21, 2024
  22. 1/2 object-name: detect and report empty reflogsPatrick Steinhardt, Feb 21, 2024
  23. Kristoffer HaugsbakkFeb 21, 2024
  24. Eric SunshineFeb 21, 2024
  25. Jeff KingFeb 21, 2024
  26. 2/2 builtin/show-branch: detect empty reflogsPatrick Steinhardt, Feb 21, 2024
  27. Jeff KingFeb 21, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.