aboutsummaryrefslogtreecommitdiffstats
path: root/diff.h
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2025-08-07 22:52:58 +0200
committerJunio C Hamano <gitster@pobox.com>2025-08-07 15:29:35 -0700
commita1dfa5448d583bbfd1ec45642a4495ad499970c9 (patch)
treec57bd65d0f3e6013e0d808fbecaa0244c42672f2 /diff.h
parentwithin_depth: fix return for empty path (diff)
downloadgit-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.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/diff.h b/diff.h
index 62e5768a9a..bbced5f745 100644
--- a/diff.h
+++ b/diff.h
@@ -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);