git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 0/8] Introduce git-blame-tree(1) command

From
Toon Claes <toon@iotcl.com>
Date
Mar 26, 2025, 20:18 UTC
Message-ID
<20250326-toon-blame-tree-v1-0-4173133f3786@iotcl.com>

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@gmail.com/ [2]: https://lore.kernel.org/git/20110302164031.GA18233@sigill.intra.peff.net/ [3]: https://github.com/peff/git/tree/jk/faster-blame-tree-wip [4]: https://lore.kernel.org/git/YN4zKVK7gvuIZ0vK@coredump.intra.peff.net/

---
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

Next: Toon Claes
Message 1 of 15 in “Introduce git-blame-tree(1) command”
  1. 0/8 Introduce git-blame-tree(1) commandToon Claes, Mar 26, 2025
  2. 1/8 combine-diff: zero memory used for callback filepairsToon Claes, Mar 26, 2025
  3. 2/8 within_depth: fix return for empty pathToon Claes, Mar 26, 2025
  4. 3/8 diff: teach tree-diff a max-depth parameterToon Claes, Mar 26, 2025
  5. 4/8 blame-tree: introduce new subcommand to blame filesToon Claes, Mar 26, 2025
  6. 5/8 pathspec: add optional trie indexToon Claes, Mar 26, 2025
  7. 6/8 pathspec: turn on tries when appropriateToon Claes, Mar 26, 2025
  8. 7/8 tree-diff: use pathspec triesToon Claes, Mar 26, 2025
  9. 8/8 blame-tree: narrow pathspec as we traverseToon Claes, Mar 26, 2025
  10. Taylor BlauMar 26, 2025
  11. Jeff KingMar 27, 2025
  12. Taylor BlauMar 27, 2025
  13. Toon ClaesMar 28, 2025
  14. Jeff KingApr 1, 2025
  15. Derrick StoleeMar 27, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.