{"thread":{"id":"64982","subject":"cat-file: dies with --batch if reflog entry is out of bounds","startedAt":"2026-02-11T23:15:36Z","lastAt":"2026-02-12T04:07:12Z","messageCount":3,"participants":["Kristoffer Haugsbakk","Junio C Hamano","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"535813","messageId":"2b07489b-1689-4ecd-9cda-012540fe56e2@app.fastmail.com","threadId":"64982","inReplyTo":null,"subject":"cat-file: dies with --batch if reflog entry is out of bounds","fromName":"Kristoffer Haugsbakk","fromEmail":"kristofferhaugsbakk@fastmail.com","sentAt":"2026-02-11T23:13:36Z","receivedAt":"2026-02-11T23:15:36Z","isPatch":false,"sender":{"key":"kristofferhaugsbakk@fastmail.com","avatar":null},"body":"    $ git cat-file --batch\n    HEAD@{7}\n    <commit>\n    branch@{20}\n    fatal: log for 'branch' only has 5 entries\n    [died]\n\nThis is a known limitation.\n\nIt used to just die without any flags until recently in 393bbb21\n(object-name: make get_oid quietly return an error, 2025-06-12).[1] That\nadded a `GET_OID_GENTLY` flag which is respected here. If that is set\nit returns normally from the function with an error.\n\nBefore that I was looking at `builtin/cat-file.c` and guessing that\n`GET_OID_GENTLY` would be the thing that made `--batch` loop on. But it\nseems to be the lack of `GET_OID_ONLY_TO_DIE`; that flag seems to be\nused when you do a one object lookup like `git cat-file commit\nHEAD`. And it is indeed not set for the batch modes.\n\n`GET_OID_GENTLY` from commit 393bbb21 was added it seems so that a\ncommit in the same series could try to look up a reflog entry in\n`builtin/stash.c` and give its own error message. And go to `cleanup` as\nwell. It’s the only user/usage.\n\nI’m pretty new to git-cat-file(1) but it seems very consistent in\nreturning “missing” for object names that don’t exist, “little red\nriding hood” and malformed rev expressions. Is this the only\ncould-be-an-object input it will die on?\n\n[1]: https://lore.kernel.org/git/20250508234458.3665894-2-sandals@crustytoothpaste.net/#t\n\n-- \nKristoffer Haugsbakk\ncode at khaugsbakk.name\n"},{"id":"535814","messageId":"xmqqcy2argqh.fsf@gitster.g","threadId":"64982","inReplyTo":"2b07489b-1689-4ecd-9cda-012540fe56e2@app.fastmail.com","subject":"Re: cat-file: dies with --batch if reflog entry is out of bounds","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-02-11T23:40:54Z","receivedAt":"2026-02-11T23:40:57Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Kristoffer Haugsbakk\" <kristofferhaugsbakk@fastmail.com> writes:\n\n>     $ git cat-file --batch\n>     HEAD@{7}\n>     <commit>\n>     branch@{20}\n>     fatal: log for 'branch' only has 5 entries\n>     [died]\n>\n> This is a known limitation.\n\nIt is pretty safe to call this a BUG, given that everywhere we seem\nto try very hard to diagnose \"you asked me about X, but that does\nnot name anything I know about\", as you found out..\n"},{"id":"535816","messageId":"20260212040708.GA1894049@coredump.intra.peff.net","threadId":"64982","inReplyTo":"2b07489b-1689-4ecd-9cda-012540fe56e2@app.fastmail.com","subject":"Re: cat-file: dies with --batch if reflog entry is out of bounds","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2026-02-12T04:07:08Z","receivedAt":"2026-02-12T04:07:12Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Feb 12, 2026 at 12:13:36AM +0100, Kristoffer Haugsbakk wrote:\n\n>     $ git cat-file --batch\n>     HEAD@{7}\n>     <commit>\n>     branch@{20}\n>     fatal: log for 'branch' only has 5 entries\n>     [died]\n> \n> This is a known limitation.\n\nI expect there are others. E.g.:\n\n  $ git checkout --detach\n  $ echo @{upstream} | git cat-file --batch\n  fatal: HEAD does not point to a branch\n\nSo I'd guess that there is probably a lot more work to be done on top of\n393bbb21 to make GET_OID_GENTLY work consistently. But doing that will\nincrementally take us in a good direction (for cat-file and for other\ncallers).\n\n-Peff\n"}]}