)]}'
{
  "commit": "b0ba57daa86dfba0a6551613452d1cb2301266a2",
  "tree": "9df6b16773cf2b259fc8426c5814db52a59fe34a",
  "parents": [
    "e8e5453ab8794cf29afe0a616d74319442b676bd"
  ],
  "author": {
    "name": "Derrick Stolee",
    "email": "stolee@gmail.com",
    "time": "Mon Apr 06 13:27:28 2026 +0000"
  },
  "committer": {
    "name": "Junio C Hamano",
    "email": "gitster@pobox.com",
    "time": "Mon Apr 06 12:02:30 2026 -0700"
  },
  "message": "rev-list: use reduce_heads() for --maximal-only\n\nThe \u0027git rev-list --maximal-only\u0027 option filters the output to only\nindependent commits. A commit is independent if it is not reachable from\nother listed commits. Currently this is implemented by doing a full\nrevision walk and marking parents with CHILD_VISITED to skip non-maximal\ncommits.\n\nThe \u0027git merge-base --independent\u0027 command computes the same result\nusing reduce_heads(), which uses the more efficient remove_redundant()\nalgorithm. This is significantly faster because it avoids walking the\nentire commit graph.\n\nAdd a fast path in rev-list that detects when --maximal-only is the only\ninteresting option and all input commits are positive (no revision\nranges). In this case, use reduce_heads() directly instead of doing a\nfull revision walk.\n\nIn order to preserve the rest of the output filtering, this computation\nis done opportunistically in a new prepare_maximal_independent() method\nwhen possible. If successful, it populates revs-\u003ecommits with the list\nof independent commits and set revs-\u003eno_walk to prevent any other walk\nfrom occurring. This allows us to have any custom output be handled\nusing the existing output code hidden inside\ntraverse_commit_list_filtered(). A new test is added to demonstrate that\nthis output is preserved.\n\nThe fast path is only used when no other flags complicate the walk or\noutput format: no UNINTERESTING commits, no limiting options (max-count,\nage filters, path filters, grep filters), no output formatting beyond\nplain OIDs, and no object listing flags.\n\nRunning the p6011 performance test for my copy of git.git, I see the\nfollowing improvement with this change:\n\n  Test                                     HEAD~1  HEAD\n  ------------------------------------------------------------\n  6011.2: merge-base --independent          0.03   0.03 +0.0%\n  6011.3: rev-list --maximal-only           0.06   0.03 -50.0%\n  6011.4: rev-list --maximal-only --since   0.06   0.06 +0.0%\n\nAnd for a fresh clone of the Linux kernel repository, I see:\n\n  Test                                     HEAD~1  HEAD\n  ------------------------------------------------------------\n  6011.2: merge-base --independent          0.00   0.00 \u003d\n  6011.3: rev-list --maximal-only           0.70   0.00 -100.0%\n  6011.4: rev-list --maximal-only --since   0.70   0.70 +0.0%\n\nIn both cases, the performance is indeed matching the behavior of \u0027git\nmerge-base --independent\u0027, as expected.\n\nSigned-off-by: Derrick Stolee \u003cstolee@gmail.com\u003e\nSigned-off-by: Junio C Hamano \u003cgitster@pobox.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "854d82ece368b389591ee7d78474a4af2568894d",
      "old_mode": 33188,
      "old_path": "builtin/rev-list.c",
      "new_id": "8f63003709242efbe6ece1ec5d2a2fe2c585e371",
      "new_mode": 33188,
      "new_path": "builtin/rev-list.c"
    },
    {
      "type": "modify",
      "old_id": "d0a2a866100d56a613acf4066621f531c25e454b",
      "old_mode": 33261,
      "old_path": "t/t6000-rev-list-misc.sh",
      "new_id": "a95ba576fa24b28bd253a976ed2b6153443c38c5",
      "new_mode": 33261,
      "new_path": "t/t6000-rev-list-misc.sh"
    }
  ]
}
