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

[PATCH 3/3] last-modified: better document how depth in handled

From
Toon Claes <toon@iotcl.com>
Date
Nov 26, 2025, 06:09 UTC
Message-ID
<20251126-toon-last-modified-zzzz-v1-3-608350df0caa@iotcl.com>
In-Reply-To
<20251126-toon-last-modified-zzzz-v1-0-608350df0caa@iotcl.com>

By default git-last-modified(1) only shows information about paths at the root level. This can be confusing. Clarify the command's behavior in the documentation.

Signed-off-by: Toon Claes <toon@iotcl.com>
---
 Documentation/git-last-modified.adoc | 43 ++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
diff --git a/Documentation/git-last-modified.adoc b/Documentation/git-last-modified.adoc
index 8409daebe9..36f72954a5 100644
--- a/Documentation/git-last-modified.adoc
+++ b/Documentation/git-last-modified.adoc
@@ -27,6 +27,7 @@ OPTIONS
 `--recursive`::
 	Instead of showing tree entries, step into subtrees and show all entries
 	inside them recursively.
+	See the section "NOTES ABOUT DEPTH" below for more details.
 
 `-t`::
 `--show-trees`::
@@ -38,6 +39,7 @@ OPTIONS
 	levels of directories. A negative value means no limit.
 	Setting a positive value implies `--recursive`.
 	Cannot be combined with wildcards in the pathspec.
+	See the section "NOTES ABOUT DEPTH" below for more details.
 
 `-z`::
 	Terminate each line with a _NUL_ rather than a newline.
@@ -70,6 +72,47 @@ avoid quoting, pass option `-z` to terminate each line with a NUL.
  <oid> TAB <path> NUL
 ------------
 
+NOTES ABOUT DEPTH
+-----------------
+
+By default this command only shows information about paths at the root level.
+When a path that lives in a subtree is provided, information about the top-level
+subtree is printed. For example:
+
+------------
+$ git last-modified -- sub/file
+
+abcd1234abcd1234abcd1234abcd1234abcd1234 sub
+------------
+
+To get details about the exact path in a subtree, add option `--recursive`:
+
+------------
+$ git last-modified --recursive -- sub/file
+
+5678abca5678abca5678abca5678abca5678abca sub/file
+------------
+
+This comes with a downside. When the path provided is a tree itself, with
+option `--recursive` all paths in that subtree are printed too:
+
+------------
+$ git last-modified --recursive -- sub/subsub
+
+1234cdef1234cdef1234cdef1234cdef1234cdef sub/subsub/a
+3456cdef3456cdef3456cdef3456cdef3456cdef sub/subsub/b
+5678abcd5678abcd5678abcd5678abcd5678abcd sub/subsub/c
+------------
+
+To stop this command from traversing deeper into trees, add option
+`--max-depth=0`:
+
+------------
+$ git last-modified --recursive --max-depth=0 -- sub/subsub
+
+3456def3456def3456def3456def3456def3456b sub/subsub
+------------
+
 SEE ALSO
 --------
 linkgit:git-blame[1],
-- 
2.51.2
Previous: Toon ClaesNext: Eric Sunshine
Message 12 of 36 in “Expand and enhance git-last-modified(1) documentation”
  1. 0/3 Expand and enhance git-last-modified(1) documentationToon Claes, Nov 26, 2025
  2. 1/3 last-modified: handle and document NUL terminationToon Claes, Nov 26, 2025
  3. Karthik NayakNov 26, 2025
  4. Junio C HamanoNov 26, 2025
  5. Toon ClaesNov 28, 2025
  6. Patrick SteinhardtDec 1, 2025
  7. 2/3 last-modified: document option --max-depthToon Claes, Nov 26, 2025
  8. Karthik NayakNov 26, 2025
  9. Toon ClaesJan 16, 2026
  10. Junio C HamanoNov 26, 2025
  11. Toon ClaesNov 28, 2025
  12. 3/3 last-modified: better document how depth in handledToon Claes, Nov 26, 2025
  13. Eric SunshineNov 26, 2025
  14. Patrick SteinhardtDec 1, 2025
  15. Toon ClaesDec 2, 2025
  16. Patrick SteinhardtDec 2, 2025
  17. 0/5 Change git-last-modified(1) default behavior and add documentationToon Claes, Jan 16, 2026
  18. 1/5 last-modified: document NUL terminationToon Claes, Jan 16, 2026
  19. 2/5 last-modified: add option '-z' to help outputToon Claes, Jan 16, 2026
  20. Junio C HamanoJan 16, 2026
  21. 3/5 last-modified: document option --max-depthToon Claes, Jan 16, 2026
  22. 4/5 last-modified: add option '--max-depth' to help outputToon Claes, Jan 16, 2026
  23. Junio C HamanoJan 16, 2026
  24. 5/5 last-modified: change default max-depth to 0Toon Claes, Jan 16, 2026
  25. Junio C HamanoJan 16, 2026
  26. Kristoffer HaugsbakkJan 16, 2026
  27. Toon ClaesJan 20, 2026
  28. 0/4 Change git-last-modified(1) default behavior and add documentationToon Claes, Jan 20, 2026
  29. 1/4 last-modified: clarify in the docs the command takes a pathspecToon Claes, Jan 20, 2026
  30. 2/4 last-modified: document option '-z'Toon Claes, Jan 20, 2026
  31. 3/4 last-modified: document option '--max-depth'Toon Claes, Jan 20, 2026
  32. 4/4 last-modified: change default max-depth to 0Toon Claes, Jan 20, 2026
  33. Kristoffer HaugsbakkJan 25, 2026
  34. Junio C HamanoJan 21, 2026
  35. Karthik NayakFeb 3, 2026
  36. Junio C HamanoFeb 3, 2026

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.