From: Caspar Duregger <caspar.duregger@gmail.com>
To: git@vger.kernel.org
Cc: Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>,
Junio C Hamano <gitster@pobox.com>, Jeff King <peff@peff.net>,
"brian m . carlson" <sandals@crustytoothpaste.net>,
Caspar Duregger <caspar.duregger@gmail.com>
Subject: [PATCH 0/4] cat-file: do not die on reflog entries out of range
Date: Fri, 13 Nov 2026 15:28:00 +0100 [thread overview]
Message-ID: <20261113142804.7465-1-caspar.duregger@gmail.com> (raw)
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
next prev parent reply other threads:[~2026-11-13 14:28 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-11 23:13 cat-file: dies with --batch if reflog entry is out of bounds Kristoffer Haugsbakk
2026-02-11 23:40 ` Junio C Hamano
2026-02-12 4:07 ` Jeff King
2026-11-13 14:28 ` Caspar Duregger [this message]
2026-11-13 14:28 ` [PATCH 1/4] object-name: do not read a peel suffix as a reflog selector Caspar Duregger
2026-11-13 14:28 ` [PATCH 2/4] object-name: let GET_OID_GENTLY affect only failing lookups Caspar Duregger
2026-11-13 14:28 ` [PATCH 3/4] refs: let read_ref_at() fail gently on an empty reflog Caspar Duregger
2026-11-13 14:28 ` [PATCH 4/4] cat-file: report out-of-range reflog entries as missing Caspar Duregger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261113142804.7465-1-caspar.duregger@gmail.com \
--to=caspar.duregger@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=kristofferhaugsbakk@fastmail.com \
--cc=peff@peff.net \
--cc=sandals@crustytoothpaste.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox