This is yet another attempt to upstream the builtin command `git-blame-tree(1)`. This command is similar to git-blame(1) and shows the most recent modification to paths in a tree.. The last attempt (I'm aware of) was made by Ævar in 2023[1]. That series was based of patches by Peff written in 2011[2]. In contrary to Ævar's attempt, my series implements the `git-blame-tree(1)` standalone command. Ævar suggested to only implement the blame-tree subsystem, and test it through test-tool. But since the command line options of that test-tool subcommand were very similar to the standalone command we want to land, I decided transfer the test-tool subcommand into a real Git builtin. Also, nowadays if we want to test the blame-tree subsystem independently, we should use clar unit tests instead of test-tool. This series brings back the --max-depth changes. I know Ævar removed them because there was controversy, but I think they are relevant to include. And I want to open up the conversation again. Also extra patches from Peff are included to implement pathspec tries. I've taken them from Peff's fork on GitHub[3], but they also have been posted to this mailing list[4]. Other improvements I've made: * Rebase onto current master. * Remove the use of USE_THE_REPOSITORY_VARIABLE. * Fix various memory leaks. * Moved code from blame-tree.c to pathspec.c, as suggested in Peff's last patch on GitHub. * Updated the benchmark results in the last commit message, although the numbers were roughly the same. I don't expect this code to be deemed ready to merge, but I mainly want to gather as much feedback as possible and use it to iterate toward actually getting it merged. There are some things I know that are missing, for example `--porcelain`, but those can be added in a follow-up. At the moment there's one test marked `test_expect_failure`, but I was not able yet identify that bug. So, let me know what you think? -- Toon [1]: https://lore.kernel.org/git/patch-1.1-0ea849d900b-20230205T204104Z-avarab@xxxxxxxxx/ [2]: https://lore.kernel.org/git/20110302164031.GA18233@xxxxxxxxxxxxxxxxxxxxx/ [3]: https://github.com/peff/git/tree/jk/faster-blame-tree-wip [4]: https://lore.kernel.org/git/YN4zKVK7gvuIZ0vK@xxxxxxxxxxxxxxxxxxxxxxx/ --- Jeff King (7): combine-diff: zero memory used for callback filepairs within_depth: fix return for empty path diff: teach tree-diff a max-depth parameter pathspec: add optional trie index pathspec: turn on tries when appropriate tree-diff: use pathspec tries blame-tree: narrow pathspec as we traverse Toon Claes (1): blame-tree: introduce new subcommand to blame files .gitignore | 1 + Documentation/diff-options.adoc | 26 +++++ Makefile | 3 + blame-tree.c | 216 ++++++++++++++++++++++++++++++++++++++++ blame-tree.h | 43 ++++++++ builtin.h | 1 + builtin/blame-tree.c | 67 +++++++++++++ combine-diff.c | 2 +- diff-lib.c | 5 + diff.c | 18 ++++ diff.h | 9 ++ dir.c | 2 +- git.c | 1 + meson.build | 2 + pathspec.c | 216 ++++++++++++++++++++++++++++++++++++++++ pathspec.h | 27 +++++ t/helper/meson.build | 1 + t/helper/test-pathspec.c | 96 ++++++++++++++++++ t/helper/test-tool.c | 1 + t/helper/test-tool.h | 2 + t/meson.build | 3 + t/perf/p4003-diff-pathspec.sh | 26 +++++ t/t4071-diff-max-depth.sh | 109 ++++++++++++++++++++ t/t6137-pathspec-trie.sh | 57 +++++++++++ t/t8020-blame-tree.sh | 142 ++++++++++++++++++++++++++ tree-diff.c | 176 +++++++++++++++++++++++++++++--- 26 files changed, 1235 insertions(+), 17 deletions(-) --- --- base-commit: 683c54c999c301c2cd6f715c411407c413b1d84e change-id: 20250326-toon-blame-tree-2ca74d7712ac Thanks -- Toon