)]}'
{
  "commit": "2816b748e5c300afda559a09426f8342c235c29d",
  "tree": "ca6562bce8200de04bde4366e7a9d4235322bf43",
  "parents": [
    "2574c617362a0c67d15fa01e01cdbd0f6bcdbc93"
  ],
  "author": {
    "name": "Patrick Steinhardt",
    "email": "ps@pks.im",
    "time": "Wed Nov 19 08:51:00 2025 +0100"
  },
  "committer": {
    "name": "Junio C Hamano",
    "email": "gitster@pobox.com",
    "time": "Tue Nov 25 12:16:00 2025 -0800"
  },
  "message": "odb: handle changing a repository\u0027s commondir\n\nThe function `repo_set_gitdir()` is called in two situations:\n\n  - To initialize the repository with its discovered location. As part\n    of this we also set up the new object database.\n\n  - To update the repository\u0027s discovered location in case the process\n    changes its working directory so that we update relative paths. This\n    means we also have to update any relative paths that are potentially\n    used in the object database.\n\nIn the context of the object database we ideally wouldn\u0027t ever have to\nworry about the second case: if all paths used by our object database\nsources were absolute, then we wouldn\u0027t have to update them. But\nunfortunately, the paths aren\u0027t only used to locate files owned by the\ngiven source, but we also use them for reporting purposes. One such\nexample is `repo_get_object_directory()`, where we cannot just change\nsemantics to always return absolute paths, as that is likely to break\ntooling out there.\n\nOne solution to this would be to have both a \"display path\" and an\n\"internal path\". This would allow us to use internal paths for all\ninternal matters, but continue to use the potentially-relative display\npaths so that we don\u0027t break compatibility. But converting the codebase\nto honor this split is quite a messy endeavour, and it wouldn\u0027t even\nhelp us with the goal to get rid of the need to update the display path\non chdir(3p).\n\nAnother solution would be to rework \"setup.c\" so that we never have to\nupdate paths in the first place. In that case, we\u0027d only initialize the\nrepository once we have figured out final locations for all directories.\nThis would be a significant simplification of that subsystem indeed, but\nthe current logic is so messy that it would take significant investments\nto get there.\n\nMeanwhile though, while object sources may still use relative paths, the\nbest thing we can do is to handle the reparenting of the object source\npaths in the object database itself. This can be done by registering one\ncallback for each object database so that we get notified whenever the\ncurrent working directory changes, and we then perform the reparenting\nourselves.\n\nIdeally, this wouldn\u0027t even happen on the object database level, but\ninstead handled by each object database source. But we don\u0027t yet have\nproper pluggable object database sources, so this will need to be\nhandled at a later point in time.\n\nThe logic itself is rather simple:\n\n  - We register the callback when creating the object database.\n\n  - We unregister the callback when releasing it again.\n\n  - We split up `set_git_dir_1()` so that it becomes possible to skip\n    recreating the object database. This is required because the\n    function is called both when the current working directory changes,\n    but also when we set up the repository. Calling this function\n    without skipping creation of the ODB will result in a bug in case\n    it\u0027s already created.\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": "88b40c81c0060c022c30ce1c19672dfa5779a0f2",
      "old_mode": 33188,
      "old_path": "odb.c",
      "new_id": "70665fb7f48f0ff4662365f5744d5118e70c84a5",
      "new_mode": 33188,
      "new_path": "odb.c"
    },
    {
      "type": "modify",
      "old_id": "41b3c03027f4d833278592e1b34040f59d055971",
      "old_mode": 33188,
      "old_path": "odb.h",
      "new_id": "014cd9585a2f6efe7367e300afd465906f4a1e3a",
      "new_mode": 33188,
      "new_path": "odb.h"
    },
    {
      "type": "modify",
      "old_id": "5975c8f341c8cb86fecf4533122f987b10ab5d5f",
      "old_mode": 33188,
      "old_path": "repository.c",
      "new_id": "863f24411b7bf9ac31ee6b2fde1af1b7848d6099",
      "new_mode": 33188,
      "new_path": "repository.c"
    },
    {
      "type": "modify",
      "old_id": "614649413b68bc6d665c893cdc2dcf9a284e2321",
      "old_mode": 33188,
      "old_path": "repository.h",
      "new_id": "6063c4b846d031d657827f8b16d65af8c09e5b29",
      "new_mode": 33188,
      "new_path": "repository.h"
    },
    {
      "type": "modify",
      "old_id": "a752e9fc8476a05e3550f4b69b5f70fd1488748d",
      "old_mode": 33188,
      "old_path": "setup.c",
      "new_id": "a625f9fbc8b1b7fb470ec652a332a8da638f3dbd",
      "new_mode": 33188,
      "new_path": "setup.c"
    }
  ]
}
