diff options
| author | Jeff King <peff@peff.net> | 2025-08-07 22:52:58 +0200 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-08-07 15:29:35 -0700 |
| commit | a1dfa5448d583bbfd1ec45642a4495ad499970c9 (patch) | |
| tree | c57bd65d0f3e6013e0d808fbecaa0244c42672f2 /diff.h | |
| parent | within_depth: fix return for empty path (diff) | |
| download | git-a1dfa5448d583bbfd1ec45642a4495ad499970c9.tar.gz git-a1dfa5448d583bbfd1ec45642a4495ad499970c9.zip | |
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>
Diffstat (limited to 'diff.h')
| -rw-r--r-- | diff.h | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -404,6 +404,14 @@ struct diff_options { struct strmap *additional_path_headers; int no_free; + + /* + * The value '0' is a valid max-depth (for no recursion), and value '-1' + * also (for unlimited recursion), so the extra "valid" flag is used to + * determined whether the user specified option --max-depth. + */ + int max_depth; + int max_depth_valid; }; unsigned diff_filter_bit(char status); |
