All of lore.kernel.org
 help / color / mirror / Atom feed
* cat-file: dies with --batch if reflog entry is out of bounds
@ 2026-02-11 23:13 Kristoffer Haugsbakk
  2026-02-11 23:40 ` Junio C Hamano
  2026-02-12  4:07 ` Jeff King
  0 siblings, 2 replies; 8+ messages in thread
From: Kristoffer Haugsbakk @ 2026-02-11 23:13 UTC (permalink / raw)
  To: git

    $ 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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-11-13 14:28 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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   ` [PATCH 0/4] cat-file: do not die on reflog entries out of range Caspar Duregger
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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.