mirror of
https://github.com/git/git.git
synced 2026-01-09 17:46:37 +00:00
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>
This commit is contained in:
committed by
Junio C Hamano
parent
2a43e0e550
commit
a1dfa5448d
@@ -115,6 +115,9 @@ void run_diff_files(struct rev_info *revs, unsigned int option)
|
||||
uint64_t start = getnanotime();
|
||||
struct index_state *istate = revs->diffopt.repo->index;
|
||||
|
||||
if (revs->diffopt.max_depth_valid)
|
||||
die(_("max-depth is not supported for worktree diffs"));
|
||||
|
||||
diff_set_mnemonic_prefix(&revs->diffopt, "i/", "w/");
|
||||
|
||||
refresh_fsmonitor(istate);
|
||||
@@ -560,6 +563,8 @@ static int diff_cache(struct rev_info *revs,
|
||||
opts.dst_index = NULL;
|
||||
opts.pathspec = &revs->diffopt.pathspec;
|
||||
opts.pathspec->recursive = 1;
|
||||
if (revs->diffopt.max_depth_valid)
|
||||
die(_("max-depth is not supported for index diffs"));
|
||||
|
||||
init_tree_desc(&t, &tree->object.oid, tree->buffer, tree->size);
|
||||
return unpack_trees(1, &t, &opts);
|
||||
|
||||
Reference in New Issue
Block a user