)]}'
{
  "commit": "5305474ec4650755f2c0437c004cabfb1c60cf6a",
  "tree": "55c6343c74bc3a9a50732d2267058f9b4574d5ad",
  "parents": [
    "43c8a30d150ecede9709c1f2527c8fba92c65f40"
  ],
  "author": {
    "name": "Victoria Dye",
    "email": "vdye@github.com",
    "time": "Mon Oct 09 21:58:53 2023 +0000"
  },
  "committer": {
    "name": "Junio C Hamano",
    "email": "gitster@pobox.com",
    "time": "Mon Oct 09 15:53:13 2023 -0700"
  },
  "message": "ref-cache.c: fix prefix matching in ref iteration\n\nUpdate \u0027cache_ref_iterator_advance\u0027 to skip over refs that are not matched\nby the given prefix.\n\nCurrently, a ref entry is considered \"matched\" if the entry name is fully\ncontained within the prefix:\n\n* prefix: \"refs/heads/v1\"\n* entry: \"refs/heads/v1.0\"\n\nOR if the prefix is fully contained in the entry name:\n\n* prefix: \"refs/heads/v1.0\"\n* entry: \"refs/heads/v1\"\n\nThe first case is always correct, but the second is only correct if the ref\ncache entry is a directory, for example:\n\n* prefix: \"refs/heads/example\"\n* entry: \"refs/heads/\"\n\nModify the logic in \u0027cache_ref_iterator_advance\u0027 to reflect these\nexpectations:\n\n1. If \u0027overlaps_prefix\u0027 returns \u0027PREFIX_EXCLUDES_DIR\u0027, then the prefix and\n   ref cache entry do not overlap at all. Skip this entry.\n2. If \u0027overlaps_prefix\u0027 returns \u0027PREFIX_WITHIN_DIR\u0027, then the prefix matches\n   inside this entry if it is a directory. Skip if the entry is not a\n   directory, otherwise iterate over it.\n3. Otherwise, \u0027overlaps_prefix\u0027 returned \u0027PREFIX_CONTAINS_DIR\u0027, indicating\n   that the cache entry (directory or not) is fully contained by or equal to\n   the prefix. Iterate over this entry.\n\nNote that condition 2 relies on the names of directory entries having the\nappropriate trailing slash. The existing function documentation of\n\u0027create_dir_entry\u0027 explicitly calls out the trailing slash requirement, so\nthis is a safe assumption to make.\n\nThis bug generally doesn\u0027t have any user-facing impact, since it requires:\n\n1. using a non-empty prefix without a trailing slash in an iteration like\n   \u0027for_each_fullref_in\u0027,\n2. the callback to said iteration not reapplying the original filter (as\n   for-each-ref does) to ensure unmatched refs are skipped, and\n3. the repository having one or more refs that match part of, but not all\n   of, the prefix.\n\nHowever, there are some niche scenarios that meet those criteria\n(specifically, \u0027rev-parse --bisect\u0027 and \u0027(log|show|shortlog) --bisect\u0027). Add\ntests covering those cases to demonstrate the fix in this patch.\n\nSigned-off-by: Victoria Dye \u003cvdye@github.com\u003e\nSigned-off-by: Junio C Hamano \u003cgitster@pobox.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "2294c4564fba3e171334314a5623928c5f27c14a",
      "old_mode": 33188,
      "old_path": "refs/ref-cache.c",
      "new_id": "6e3b725245c3e8df1ec666cc23ab51b718be1d1f",
      "new_mode": 33188,
      "new_path": "refs/ref-cache.c"
    },
    {
      "type": "modify",
      "old_id": "37ee5091b5caa7c087663cbb51f701084227c414",
      "old_mode": 33261,
      "old_path": "t/t1500-rev-parse.sh",
      "new_id": "3f9e7f62e458c4db06a686700a15c5e08f47fad9",
      "new_mode": 33261,
      "new_path": "t/t1500-rev-parse.sh"
    },
    {
      "type": "modify",
      "old_id": "dd9035aa384937bfec5793fe2f591032282837ac",
      "old_mode": 33261,
      "old_path": "t/t4205-log-pretty-formats.sh",
      "new_id": "b431a22bbd7794ea96e3d33e5e546d6da875b1a1",
      "new_mode": 33261,
      "new_path": "t/t4205-log-pretty-formats.sh"
    }
  ]
}
