public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
From: "Kristoffer Haugsbakk" <kristofferhaugsbakk@fastmail.com>
To: git@vger.kernel.org
Subject: cat-file: dies with --batch if reflog entry is out of bounds
Date: Thu, 12 Feb 2026 00:13:36 +0100	[thread overview]
Message-ID: <2b07489b-1689-4ecd-9cda-012540fe56e2@app.fastmail.com> (raw)

    $ git cat-file --batch
    HEAD@{7}
    <commit>
    branch@{20}
    fatal: log for 'branch' only has 5 entries
    [died]

This is a known limitation.

It used to just die without any flags until recently in 393bbb21
(object-name: make get_oid quietly return an error, 2025-06-12).[1] That
added a `GET_OID_GENTLY` flag which is respected here. If that is set
it returns normally from the function with an error.

Before that I was looking at `builtin/cat-file.c` and guessing that
`GET_OID_GENTLY` would be the thing that made `--batch` loop on. But it
seems to be the lack of `GET_OID_ONLY_TO_DIE`; that flag seems to be
used when you do a one object lookup like `git cat-file commit
HEAD`. And it is indeed not set for the batch modes.

`GET_OID_GENTLY` from commit 393bbb21 was added it seems so that a
commit in the same series could try to look up a reflog entry in
`builtin/stash.c` and give its own error message. And go to `cleanup` as
well. It’s the only user/usage.

I’m pretty new to git-cat-file(1) but it seems very consistent in
returning “missing” for object names that don’t exist, “little red
riding hood” and malformed rev expressions. Is this the only
could-be-an-object input it will die on?

[1]: https://lore.kernel.org/git/20250508234458.3665894-2-sandals@crustytoothpaste.net/#t

-- 
Kristoffer Haugsbakk
code at khaugsbakk.name

             reply	other threads:[~2026-02-11 23:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-11 23:13 Kristoffer Haugsbakk [this message]
2026-02-11 23:40 ` cat-file: dies with --batch if reflog entry is out of bounds Junio C Hamano
2026-02-12  4:07 ` Jeff King

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=2b07489b-1689-4ecd-9cda-012540fe56e2@app.fastmail.com \
    --to=kristofferhaugsbakk@fastmail.com \
    --cc=git@vger.kernel.org \
    /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