# Series would stop git cat-file --batch from dying on out-of-range reflog selectors

_A four-patch series first has to fix several quirks in GET_OID_GENTLY handling so the flag only changes lookups that would otherwise die._

Section: Patches. Edition of 2026-11-14. Written by an AI editor from the thread "cat-file: dies with --batch if reflog entry is out of bounds" (8 messages): https://gitlist.dev/t/64982

Kristoffer Haugsbakk originally reported that git cat-file --batch dies when given a reflog selector past the end of the reflog, such as branch@{20} when only 5 entries exist. He noted this is a known limitation. Before commit 393bbb21 (2025-06-12) it died without any flags, and that commit added GET_OID_GENTLY to turn the die() into an error return.

Caspar Duregger, who says he is "necroposting" with a patch, runs one cat-file --batch-check process per worktree. He works around the crash with git rev-parse, which he calls sad. The main patch passes GET_OID_GENTLY from cat-file so these lookups are reported as missing like any other unresolvable name, instead of killing the process and any requests queued behind it.

He says that flag cannot simply be passed on its own, because it would change answers rather than only failures. Today ref@{N} for a reflog with N entries and ref@{<old date>} resolve, but they would fail with the flag. One earlier patch moves the check into the if/else cascade just before the die(), so the flag changes only how a failing lookup fails. He says this picks up a question raised in review of the series that added the flag.

Two further patches deal with edge cases. When a reflog exists but is empty, for example after git reflog expire --expire=all, read_ref_at() can answer ref@{0} but otherwise dies even with GET_OID_GENTLY. The patch returns -1 in that case, and git stash export on an emptied stash reflog would then report "unable to find stash entry" instead of exiting silently. Another patch stops get_oid_basic() from taking the last "@{" as a selector in names like HEAD@{1}^{blob}, where a failed peel could otherwise resolve to the current value of HEAD.

The excerpts show no review responses to the series yet.
