)]}'
{
  "commit": "2abc7f0304606e23199416ffa3dbc84fa2d431d3",
  "tree": "98e28d1380e424da107b6e63ac64fc3412e826c6",
  "parents": [
    "e9019fcafe0040228b8631c30f97ae1adb61bcdc"
  ],
  "author": {
    "name": "Jeff King",
    "email": "peff@peff.net",
    "time": "Tue Jul 28 11:00:31 2026 -0400"
  },
  "committer": {
    "name": "Junio C Hamano",
    "email": "gitster@pobox.com",
    "time": "Tue Jul 28 10:29:37 2026 -0700"
  },
  "message": "cat-file: handle content request for --batch-command without type\n\nThe batch mode of cat-file needs to know the object\u0027s type in order to\nprint the contents (because it decides whether to stream or not based on\nobject type). The default batch output contains %(objecttype), so we get\nthe type info automatically. But when it doesn\u0027t, we have to ask for it\nexplicitly.\n\nIn the --batch code path, we check while setting up the object_info\nstruct whether we will print the contents, and if so set \"typep\" to get\nthe value. This comes from 6554dfa97a (cat-file: handle --batch format\nwith missing type/size, 2013-12-12).\n\nBut later we added a --batch-command mode, which does not do the same\ntrick. The decision about whether to retrieve the contents is made\nper-command (a \"contents\" vs \"info\" command), so we can\u0027t decide when\nbuilding the object_info originally. As a result, asking for:\n\n  echo \"contents HEAD\" | git cat-file --batch-command\u003d\"%(objectname)\"\n\nwill fail the assertion in print_object_or_die() that the type was\nactually filled in.\n\nWe can fix it by tweaking the object_info on the fly as we receive each\ncommand. But we should be careful to restore it afterwards; otherwise a\nsequence of commands like:\n\n  contents $one\n  info $two\n  info $three\n\nwill pay the type-lookup price for $two and $three when it does not need\nto. This wouldn\u0027t be incorrect, but just slightly inefficient (and hence\nthere are no tests for that part, because the externally-visible\nbehavior is the same).\n\nReported-by: Alan Stokes \u003calan@source.dev\u003e\nHelped-by: Pablo Sabater \u003cpabloosabaterr@gmail.com\u003e\nSigned-off-by: Jeff King \u003cpeff@peff.net\u003e\nSigned-off-by: Junio C Hamano \u003cgitster@pobox.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "d6ef8414ee5a0ba7a015bbd79f19aedafc713493",
      "old_mode": 33188,
      "old_path": "builtin/cat-file.c",
      "new_id": "826a1c6620fcc2a3b7feb9ad60076ef5e521977c",
      "new_mode": 33188,
      "new_path": "builtin/cat-file.c"
    },
    {
      "type": "modify",
      "old_id": "8e2c52652c5185db30318a81cf2b7e4e7f118a09",
      "old_mode": 33261,
      "old_path": "t/t1006-cat-file.sh",
      "new_id": "d0db1f2a2917da9a5947d9c6cfa19506a90bdc82",
      "new_mode": 33261,
      "new_path": "t/t1006-cat-file.sh"
    }
  ]
}
