# cat-file: dies with --batch if reflog entry is out of bounds

3 messages from 2026-02-11 to 2026-02-12. Participants: Kristoffer Haugsbakk, Junio C Hamano, Jeff King.
Thread: https://gitlist.dev/t/64982

## Kristoffer Haugsbakk, 2026-02-11 23:13

Subject: cat-file: dies with --batch if reflog entry is out of bounds
Message-ID: <2b07489b-1689-4ecd-9cda-012540fe56e2@app.fastmail.com>
URL: https://gitlist.dev/e/2b07489b-1689-4ecd-9cda-012540fe56e2%40app.fastmail.com

```
    $ 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

```

## Junio C Hamano, 2026-02-11 23:40

Subject: Re: cat-file: dies with --batch if reflog entry is out of bounds
Message-ID: <xmqqcy2argqh.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqqcy2argqh.fsf%40gitster.g
In-Reply-To: <2b07489b-1689-4ecd-9cda-012540fe56e2@app.fastmail.com>

```
"Kristoffer Haugsbakk" <kristofferhaugsbakk@fastmail.com> writes:

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

It is pretty safe to call this a BUG, given that everywhere we seem
to try very hard to diagnose "you asked me about X, but that does
not name anything I know about", as you found out..

```

## Jeff King, 2026-02-12 04:07

Subject: Re: cat-file: dies with --batch if reflog entry is out of bounds
Message-ID: <20260212040708.GA1894049@coredump.intra.peff.net>
URL: https://gitlist.dev/e/20260212040708.GA1894049%40coredump.intra.peff.net
In-Reply-To: <2b07489b-1689-4ecd-9cda-012540fe56e2@app.fastmail.com>

```
On Thu, Feb 12, 2026 at 12:13:36AM +0100, Kristoffer Haugsbakk wrote:

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

I expect there are others. E.g.:

  $ git checkout --detach
  $ echo @{upstream} | git cat-file --batch
  fatal: HEAD does not point to a branch

So I'd guess that there is probably a lot more work to be done on top of
393bbb21 to make GET_OID_GENTLY work consistently. But doing that will
incrementally take us in a good direction (for cat-file and for other
callers).

-Peff

```
