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

Re: Segfault: git show-branch --reflog refs/pullreqs/1

From
Patrick Steinhardt <ps@pks.im>
Date
Feb 22, 2024, 09:02 UTC
Message-ID
<ZdcNtxw04MtybTWZ@tanuki>
In-Reply-To
<xmqqv86hogpi.fsf@gitster.g>
On Wed, Feb 21, 2024 at 09:44:09AM -0800, Junio C Hamano wrote:
Show 21 quoted lines
> Jeff King <peff@peff.net> writes:
> 
> > with an empty reflog file (added by that same commit). The code in
> > get_oid_basic() to parse reflogs doesn't suffer from the same bugs: it
> > checks up front that the reflog file exists, it preloads the output oid
> > with the current ref value, and it doesn't look at other fields (like
> > the reflog message).
> 
> It is a usability hack to allow foo@{0} to resolve successfully,
> instead of causing a failure, when there is no reflog entries for
> foo, I would think.  As to the "show-branch -g", the intent is to
> see the recent evolution of the branch, so I am fine if we do not
> give any output when no reflog entries exist (i.e. "no evolution
> behind the current state---it just is"), or just one entry output
> for "foo@{0}" to say "there is only one recent state".
> 
> Even though it may feel wrong to successfully resolve foo@{0} when
> reflog for foo does not exist at the mechanical level (read: the
> implementors of reflog mechanism may find the usability hack a bad
> idea), I suspect at the end-user level it may be closer to what
> people expect out of foo@{0} (i.e. "give me the latest").

Hum, I dunno. I don't really understand what the benefit of this fallback is. If a user wants to know the latest object ID of the ref they shouldn't ask for `foo@{0}`, they should ask for `foo`. On the other hand, if I want to know "What is the latest entry in the ref's log", I want to ask for `foo@{0}`.

For one, I think that this is adding complexity to the user interface. If you were to explain this feature to a user who has never encountered it, you need to now also explain special cases: "It gives you the latest reflog entry, except when the reflog doesn't exist or is missing, then we return the object ID of the corresponding ref." This is a lot more mental overhead than "It gives you the latest reflog entry."

We also have to consider a potential future where we stop deleting reflogs together with their ref in the "reftable" backend. What do we return when the reflog is empty and the ref is missing? "It gives you the latest reflog entry, except when the reflog doesn't exist or is missing, then we give you the ref except if that is missing, too". It's getting even harder to explain now.

Another angle to me is scripting. If I really want to get the latest reflog entry, then I now have to execute two commands. First I have to check whether the reflog is non-empty, and only then can I ask for the latest reflog entry. Otherwise, I might not get a reflog entry but the resolved ref instead. And I wouldn't even know how to check whether the reflog is non-empty.

So overall, I think the interface is a lot easier to understand and use correctly if we didn't have this fallback.

Patrick
Previous: Junio C HamanoNext: Junio C Hamano
Message 6 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.