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

[PATCH 0/4] cat-file: do not die on reflog entries out of range

From
CDCaspar Duregger <caspar.duregger@gmail.com>
Date
Nov 13, 2026, 14:28 UTC
Message-ID
<20261113142804.7465-1-caspar.duregger@gmail.com>
In-Reply-To
<20260212040708.GA1894049@coredump.intra.peff.net>
Hi,
I necropost with a patch as I stumbled on this the other day.

I have one "git cat-file --batch-check" process per worktree, but it dies on "ref@{N}" past the end of the reflog. I work around by using the old "git rev-parse" for these but it's sad.

Passing GET_OID_GENTLY from cat-file is the obvious fix, but on its own it would change answers, not only failures:

 - "ref@{N}" for a reflog with N entries and "ref@{<old date>}"
   resolve today, but fail with GET_OID_GENTLY (patch 2, which picks
   up a review question from the series that added the flag [1]);
 - "ref@{999999}^{tree}" would resolve to the current value of the
   ref instead of dying, because after the peel fails get_oid_basic()
   reads "999999}^{tree}" as an approxidate. The same bug already
   makes "git rev-parse --verify 'HEAD@{1}^{blob}'" print a commit
   (patch 1);
 - an emptied reflog still dies inside read_ref_at() (patch 3).

Patch 4 then flips the flag in cat-file. As Peff noted, this does not make batch lookups die-free: "HEAD@{999999}~1" and "@{upstream}" on a detached HEAD still die. The former needs get_parent() and get_nth_ancestor() to pass flags down, which I left for a separate series.

[1] https://lore.kernel.org/git/xmqqa5745ttw.fsf@gitster.g/
Caspar Duregger (4):
  object-name: do not read a peel suffix as a reflog selector
  object-name: let GET_OID_GENTLY affect only failing lookups
  refs: let read_ref_at() fail gently on an empty reflog
  cat-file: report out-of-range reflog entries as missing
 builtin/cat-file.c         |  1 +
 object-name.c              | 28 +++++++++++++++++++---------
 refs.c                     |  2 ++
 refs.h                     |  4 ++++
 t/t1006-cat-file.sh        | 35 +++++++++++++++++++++++++++++++++++
 t/t1508-at-combinations.sh |  4 ++++
 t/t3903-stash.sh           | 17 +++++++++++++++++
 7 files changed, 82 insertions(+), 9 deletions(-)
-- 
2.56.1.windows.1
Previous: Jeff KingNext: Caspar Duregger
Message 4 of 8 in “cat-file: dies with --batch if reflog entry is out of bounds”
  1. Kristoffer HaugsbakkFeb 11, 2026
  2. Junio C HamanoFeb 11, 2026
  3. Jeff KingFeb 12, 2026
  4. 0/4 cat-file: do not die on reflog entries out of rangeCaspar Duregger, Nov 13, 2026
  5. 1/4 object-name: do not read a peel suffix as a reflog selectorCaspar Duregger, Nov 13, 2026
  6. 2/4 object-name: let GET_OID_GENTLY affect only failing lookupsCaspar Duregger, Nov 13, 2026
  7. 3/4 refs: let read_ref_at() fail gently on an empty reflogCaspar Duregger, Nov 13, 2026
  8. 4/4 cat-file: report out-of-range reflog entries as missingCaspar Duregger, Nov 13, 2026

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.