)]}'
{
  "commit": "320572c43d7bc5afbcb8e5faf83b6eccfe6f4e32",
  "tree": "59f08e26a626f6831fe25d4adf8b9b7135be096a",
  "parents": [
    "8613c2bb6cd16ef530dc5dd74d3b818a1ccbf1c0"
  ],
  "author": {
    "name": "Patrick Steinhardt",
    "email": "ps@pks.im",
    "time": "Wed May 28 14:24:10 2025 +0200"
  },
  "committer": {
    "name": "Junio C Hamano",
    "email": "gitster@pobox.com",
    "time": "Wed May 28 07:56:29 2025 -0700"
  },
  "message": "packfile: explain ordering of how we look up auxiliary pack files\n\nWhen adding a packfile to an object database we perform four syscalls:\n\n  - Three calls to access(3p) are done to check for auxiliary data\n    structures.\n\n  - One call to stat(3p) is done to check for the \".pack\" itself.\n\nOne curious bit is that we perform the access(3p) calls before checking\nfor the packfile itself, but if the packfile doesn\u0027t exist we discard\nall results. The access(3p) calls are thus essentially wasted, so one\nmay be triggered to reorder those calls so that we can short-circuit the\nother syscalls in case the packfile does not exist.\n\nThe order in which we look up files is quite important though to help\navoid races:\n\n  - When installing a packfile we move auxiliary data structures into\n    place before we install the \".idx\" file.\n\n  - When deleting a packfile we first delete the \".idx\" and \".pack\"\n    files before deleting auxiliary data structures.\n\nAs such, to avoid any races with concurrently created or deleted packs\nwe need to make sure that we _first_ read auxiliary data structures\nbefore we read the corresponding \".idx\" or \".pack\" file. Otherwise it\nmay easily happen that we return a populated but misclassified pack.\n\nAdd a comment to `add_packed_git()` to make future readers aware of this\nordering requirement.\n\nSigned-off-by: Patrick Steinhardt \u003cps@pks.im\u003e\nSigned-off-by: Junio C Hamano \u003cgitster@pobox.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "d91016f1c7ff401a629def8971b3da819f998909",
      "old_mode": 33188,
      "old_path": "packfile.c",
      "new_id": "933036e26062f16771a73d7a1700f316534d286e",
      "new_mode": 33188,
      "new_path": "packfile.c"
    }
  ]
}
