)]}'
{
  "commit": "8dc22e87f000a092b62b4fb08e2542433f1ae192",
  "tree": "8cee88e53c191b1fe84e47fbcc67864cf684f59c",
  "parents": [
    "5d795b34dcbf46039c3dda028bb8df8d75a5a9d0"
  ],
  "author": {
    "name": "Patrick Steinhardt",
    "email": "ps@pks.im",
    "time": "Wed Nov 19 08:50:55 2025 +0100"
  },
  "committer": {
    "name": "Junio C Hamano",
    "email": "gitster@pobox.com",
    "time": "Tue Nov 25 12:15:59 2025 -0800"
  },
  "message": "builtin/index-pack: fix deferred fsck outside repos\n\nWhen asked to perform object consistency checks via the `--fsck-objects`\nflag we verify that each object part of the pack is valid. In general,\nthis check can even be performed outside of a Git repository: we don\u0027t\nneed an initialized object database as we simply read the object from\nthe packfile directly.\n\nBut there\u0027s one exception: a subset of the object checks may be deferred\nto a later point in time. For now, this only concerns \".gitmodules\" and\n\".gitattributes\" files: whenever we see a tree referencing these files\nwe queue them for a deferred check. This is done because we need to do\nsome extra checks for those files to ensure that they are well-formed,\nand these checks need to be done regardless of whether the corresponding\nblobs are part of the packfile or not.\n\nThis works inside a repository, but unfortunately the logic leads to a\nsegfault when running outside of one. This is because we eventually call\n`odb_read_object()`, which will crash because the object database has\nnot been initialized.\n\nThere\u0027s multiple options here:\n\n  - We could in theory create a purely in-memory database with only a\n    packfile store that contains the single packfile. We don\u0027t really\n    have the infrastructure for this yet though, and it would end up\n    being quite hacky.\n\n  - We could refuse to perform consistency checks outside of a\n    repository. But most of the checks work alright, so this would be a\n    regression.\n\n  - We can skip the finalizing consistency checks when running outside\n    of a repository. This is not as invasive as skipping all checks,\n    but it\u0027s not great to randomly skip a subset of tests, either.\n\nNone of these options really feel perfect. The first one would be the\nobvious choice if easily possible.\n\nThere\u0027s another option though: instead of skipping the final object\nchecks, we can die if there are any queued object checks. With this\nchange we now die exactly if and only if we would have previously\nsegfaulted. Like this we ensure that objects that _may_ fail the\nconsistency checks won\u0027t be silently skipped, and at the same time we\ngive users a much better error message.\n\nRefactor the code accordingly and add a test that would have triggered\nthe segfault. Note that we also move down the logic to add the packfile\nto the store. There is no point doing this any earlier than right before\nwe execute `fsck_finish()`, and it ensures that the logic to set up and\nperform the consistency check is self-contained.\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": "2b78ba7fe4d14a8bcb12165395ff02deeb8c047f",
      "old_mode": 33188,
      "old_path": "builtin/index-pack.c",
      "new_id": "699fe678cd60b0af8b7edf77f2204a064140d94a",
      "new_mode": 33188,
      "new_path": "builtin/index-pack.c"
    },
    {
      "type": "modify",
      "old_id": "341e100d24ece03992d9b10d6c91c5bea089b752",
      "old_mode": 33188,
      "old_path": "fsck.c",
      "new_id": "8e1565fe6d013340307bd888b1b203ae37efe88e",
      "new_mode": 33188,
      "new_path": "fsck.c"
    },
    {
      "type": "modify",
      "old_id": "cb6ef32f4f3aaa1ac2ff8a97e38ab9b60b4fadf9",
      "old_mode": 33188,
      "old_path": "fsck.h",
      "new_id": "336917c0451aacc74db1534d21f55ded0baeb8be",
      "new_mode": 33188,
      "new_path": "fsck.h"
    },
    {
      "type": "modify",
      "old_id": "413c99274c8f3029cf259ca60c70c31348da12b8",
      "old_mode": 33261,
      "old_path": "t/t5302-pack-index.sh",
      "new_id": "9697448cb276341b11d3541334aae4b88c668997",
      "new_mode": 33261,
      "new_path": "t/t5302-pack-index.sh"
    }
  ]
}
