]> git.ipfire.org Git - thirdparty/git.git/commit
diff: teach tree-diff a max-depth parameter
authorJeff King <peff@peff.net>
Thu, 7 Aug 2025 20:52:58 +0000 (22:52 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 7 Aug 2025 22:29:35 +0000 (15:29 -0700)
commita1dfa5448d583bbfd1ec45642a4495ad499970c9
treec57bd65d0f3e6013e0d808fbecaa0244c42672f2
parent2a43e0e5503f52fd4c06faddf6c83b5678dedfe3
diff: teach tree-diff a max-depth parameter

When you are doing a tree-diff, there are basically two options: do not
recurse into subtrees at all, or recurse indefinitely. While most
callers would want to always recurse and see full pathnames, some may
want the efficiency of looking only at a particular level of the tree.
This is currently easy to do for the top-level (just turn off
recursion), but you cannot say "show me what changed in subdir/, but do
not recurse".

This patch adds a max-depth parameter which is measured from the closest
pathspec match, so that you can do:

  git log --raw --max-depth=1 -- a/b/c

and see the raw output for a/b/c/, but not those of a/b/c/d/
(instead of the raw output you would see for a/b/c/d).

Co-authored-by: Toon Claes <toon@iotcl.com>
Signed-off-by: Toon Claes <toon@iotcl.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/diff-options.adoc
diff-lib.c
diff.c
diff.h
t/meson.build
t/t4072-diff-max-depth.sh [new file with mode: 0755]
tree-diff.c