)]}'
{
  "commit": "db9d67f2e9c9ea389f5558d6a168460d51631769",
  "tree": "480ef901948f38b409cc9148bca64c5f1a04d97a",
  "parents": [
    "3639fefe7d1d7bf881ea6128cedc4fc503164edc"
  ],
  "author": {
    "name": "Taylor Blau",
    "email": "me@ttaylorr.com",
    "time": "Fri Jul 22 19:29:05 2022 -0400"
  },
  "committer": {
    "name": "Junio C Hamano",
    "email": "gitster@pobox.com",
    "time": "Fri Jul 22 21:42:06 2022 -0700"
  },
  "message": "builtin/cat-file.c: support NUL-delimited input with `-z`\n\nWhen callers are using `cat-file` via one of the stdin-driven `--batch`\nmodes, all input is newline-delimited. This presents a problem when\ncallers wish to ask about, e.g. tree-entries that have a newline\ncharacter present in their filename.\n\nTo support this niche scenario, introduce a new `-z` mode to the\n`--batch`, `--batch-check`, and `--batch-command` suite of options that\ninstructs `cat-file` to treat its input as NUL-delimited, allowing the\nindividual commands themselves to have newlines present.\n\nThe refactoring here is slightly unfortunate, since we turn loops like:\n\n    while (strbuf_getline(\u0026buf, stdin) !\u003d EOF)\n\ninto:\n\n    while (1) {\n        int ret;\n        if (opt-\u003enul_terminated)\n            ret \u003d strbuf_getline_nul(\u0026input, stdin);\n        else\n            ret \u003d strbuf_getline(\u0026input, stdin);\n\n        if (ret \u003d\u003d EOF)\n            break;\n    }\n\nIt\u0027s tempting to think that we could use `strbuf_getwholeline()` and\nspecify either `\\n` or `\\0` as the terminating character. But for input\non platforms that include a CR character preceeding the LF, this\nwouldn\u0027t quite be the same, since `strbuf_getline(...)` will trim any\ntrailing CR, while `strbuf_getwholeline(\u0026buf, stdin, \u0027\\n\u0027)` will not.\n\nIn the future, we could clean this up further by introducing a variant\nof `strbuf_getwholeline()` that addresses the aforementioned gap, but\nthat approach felt too heavy-handed for this pair of uses.\n\nSome tests are added in t1006 to ensure that `cat-file` produces the\nsame output in `--batch`, `--batch-check`, and `--batch-command` modes\nwith and without the new `-z` option.\n\nSigned-off-by: Taylor Blau \u003cme@ttaylorr.com\u003e\nSigned-off-by: Junio C Hamano \u003cgitster@pobox.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "24a811f0ef64b0f411c23a3598e7bc73e6a2e7ee",
      "old_mode": 33188,
      "old_path": "Documentation/git-cat-file.txt",
      "new_id": "3515350ed623e9cb88431140b37a4ef805742ec9",
      "new_mode": 33188,
      "new_path": "Documentation/git-cat-file.txt"
    },
    {
      "type": "modify",
      "old_id": "f42782e955f35bdfa9a78c217337863364bce1d5",
      "old_mode": 33188,
      "old_path": "builtin/cat-file.c",
      "new_id": "c3602d15df621ae3223e4f91c71854c807ffcbcb",
      "new_mode": 33188,
      "new_path": "builtin/cat-file.c"
    },
    {
      "type": "modify",
      "old_id": "01c053576513cd03dd07e806157d9b9cd8379e07",
      "old_mode": 33261,
      "old_path": "t/t1006-cat-file.sh",
      "new_id": "23b8942edba45c32822886ee93acef9b5474ea02",
      "new_mode": 33261,
      "new_path": "t/t1006-cat-file.sh"
    }
  ]
}
