Assertion failure with git cat-file --batch-command
From: Alan Stokes <hidden>
Date: 2026-07-27 09:30:55
I unexpectedly managed to hit this: git: builtin/cat-file.c:387: print_object_or_die: Assertion `data->info.typep' failed. Aborted (core dumped) (That's in print_object_or_die().) Here's the bugreport. Thank you for filling out a Git bug report! Please answer the following questions to help us understand your issue. What did you do before the bug happened? (Steps to reproduce your issue) ~$ mkdir foo ~$ cd foo ~/foo$ git init Initialized empty Git repository in /home/alan/foo/.git/ ~/foo (main)$ echo hello > hello ~/foo (main)$ git add hello ~/foo (main)$ git commit -m"first" [main (root-commit) d62fc70] first 1 file changed, 1 insertion(+) create mode 100644 hello ~/foo (main)$ git ls-tree HEAD 100644 blob ce013625030ba8dba906f756967f9e9ca394464a hello ~/foo (main)$ echo ce013625030ba8dba906f756967f9e9ca394464a | git cat-file --batch="%(objectsize)" 6 hello ~/foo (main)$ echo info ce013625030ba8dba906f756967f9e9ca394464a | git cat-file --batch-command="%(objectsize)" 6 ~/foo (main)$ echo contents ce013625030ba8dba906f756967f9e9ca394464a | git cat-file --batch-command="%(objecttype) %(objectsize)" blob 6 hello ~/foo (main)$ echo contents ce013625030ba8dba906f756967f9e9ca394464a | git cat-file --batch-command="%(objectsize)" 6 git: builtin/cat-file.c:387: print_object_or_die: Assertion `data->info.typep' failed. Aborted (core dumped) What did you expect to happen? (Expected behavior) cat-file prints the size of the blob and then the blob contents What happened instead? (Actual behavior) Assertion failure, core dump What's different between what you expected and what actually happened? The abort Anything else you want to add: I first observed this in 2.43.0, but it still seems to be present in 2.54.0. Note that if I ask git cat-file --batch-command to include the objecttype in the output it is fine (which gives me a workaround). Or if I use git cat-file --batch. IIUC git only fetches the metadata that it needs for each object, and that is determined from the format. For --batch I guess the type is always requested, since it is needed to print the object contents. But for --batch-command that doesn't seem to happen. I'm not sure what the correct fix is - always request the type in --batch-command, or perhaps only if a "contents" command is issued? Please review the rest of the bug report below. You can delete any lines you don't wish to share. [System Info] git version: git version 2.54.0 cpu: x86_64 no commit associated with this build sizeof-long: 8 sizeof-size_t: 8 shell-path: /bin/sh rust: disabled gettext: enabled libcurl: 8.5.0 zlib: 1.3 SHA-1: SHA1_DC SHA-256: SHA256_BLK default-ref-format: files default-hash: sha1 uname: Linux 7.0.0-28-generic #28~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Jul 1 15:50:57 UTC 2 x86_64 compiler info: gnuc: 13.3 libc info: glibc: 2.39 $SHELL (typically, interactive shell): /bin/bash [Enabled Hooks] Best wishes, Alan