)]}'
{
  "commit": "e900d494dcff7bb9033865e61b452128ff232481",
  "tree": "6b5af494f056424f480f645f56b9facd5d59ac72",
  "parents": [
    "c6102b758572c7515f606b2423dfe38934fe6764"
  ],
  "author": {
    "name": "Ævar Arnfjörð Bjarmason",
    "email": "avarab@gmail.com",
    "time": "Thu Feb 11 11:45:34 2021 +0100"
  },
  "committer": {
    "name": "Junio C Hamano",
    "email": "gitster@pobox.com",
    "time": "Thu Feb 11 09:21:05 2021 -0800"
  },
  "message": "diff: add an API for deferred freeing\n\nAdd a diff_free() function to free anything we may have allocated in\nthe \"diff_options\" struct, and the ability to make calling it a noop\nby setting \"no_free\" in \"diff_options\".\n\nThis is required because when e.g. \"git diff\" is run we\u0027ll allocate\nthings in that struct, use the diff machinery once, and then exit.\n\nBut if we run e.g. \"git log -p\" we\u0027re going to re-use what we\nallocated across multiple diff_flush() calls, and only want to free\nthings at the end.\n\nWe\u0027ve thus ended up with features like the recently added \"diff -I\"[1]\nwhere we\u0027ll leak memory. As it turns out it could have simply used the\npattern established in 6ea57703f6 (log: prepare log/log-tree to reuse\nthe diffopt.close_file attribute, 2016-06-22).\n\nManually adding more such flags to things log_tree_commit() every time\nwe need to allocate something would be tedious. Let\u0027s instead move\nthat fclose() code it to a new diff_free(), in anticipation of freeing\nmore things in that function in follow-up commits.\n\nSome functions such as log_tree_commit() need an idiom of optionally\nretaining a previous \"no_free\", as they may either free the memory\nthemselves, or their caller may do so. I\u0027m keeping that idiom in\nlog_show_early() for good measure, even though I don\u0027t think it\u0027s\ncurrently called in this manner. It also gets passed an existing\n\"struct rev_info\", so future callers may want to set the \"no_free\"\nflag.\n\nThis change is a bit hard to read because while the freeing pattern\nwe\u0027re introducing isn\u0027t unusual, the \"file\" member is a special\nsnowflake. We usually don\u0027t want to fclose() it. This is because\n\"file\" is usually stdout, in which case we don\u0027t want to fclose()\nit. We only want to opt-in to closing it when we e.g. open a file on\nthe filesystem. Thus the opt-in \"close_file\" flag.\n\nSo the API in general just needs a \"no_free\" flag to defer freeing,\nbut the \"file\" member still needs its \"close_file\" flag. This is made\nmore confusing because while refactoring this code we could replace\nsome \"close_file\u003d0\" with \"no_free\u003d1\", whereas others need to set both\nflags.\n\nThis is because there were some cases where an existing \"close_file\u003d0\"\nmeant \"let\u0027s defer deallocation\", and others where it meant \"we don\u0027t\nwant to close this file handle at all\".\n\n1. 296d4a94e7 (diff: add -I\u003cregex\u003e that ignores matching changes,\n   2020-10-20)\n\nSigned-off-by: Ævar Arnfjörð Bjarmason \u003cavarab@gmail.com\u003e\nSigned-off-by: Junio C Hamano \u003cgitster@pobox.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "d0cbaaf68a083f0cfa3294804f606b5cb6dff5c4",
      "old_mode": 33188,
      "old_path": "builtin/log.c",
      "new_id": "fffaf51970d3554e4d01c587bb045225184b8135",
      "new_mode": 33188,
      "new_path": "builtin/log.c"
    },
    {
      "type": "modify",
      "old_id": "69e3bc00ed8f72ad8d012175541166a6cec4ffcd",
      "old_mode": 33188,
      "old_path": "diff.c",
      "new_id": "a63c9ecae7959a22978927037aac0d1cb4713e52",
      "new_mode": 33188,
      "new_path": "diff.c"
    },
    {
      "type": "modify",
      "old_id": "2ff2b1c7f2ca05ca8c2c194f6a7447fb0965dbed",
      "old_mode": 33188,
      "old_path": "diff.h",
      "new_id": "527fb56d8517deab8eb9125c3a00971f58707630",
      "new_mode": 33188,
      "new_path": "diff.h"
    },
    {
      "type": "modify",
      "old_id": "e048467650770510b41afb92678d0a807c34764d",
      "old_mode": 33188,
      "old_path": "log-tree.c",
      "new_id": "e7fcd70ba1758639bb927e896cada9a8477c4a7e",
      "new_mode": 33188,
      "new_path": "log-tree.c"
    }
  ]
}
