tree-walk: lose base_offset that is never used in tree_entry_interesting

The tree_entry_interesting() function takes base_offset, allowing its callers to potentially pass a non-zero number to skip the early part of the path string. The feature is never exercised and we do not even know what bugs are lurking there, as all callers pass 0 to the parameter. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Jul 7, 2023 at 15:21 UTC 0ad927e9e0013471cc752781f0c368f862934a44
6 files changed +8 -7
builtin/grep.c
+1 -1
@@ -639,7 +639,7 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,
639 strbuf_addstr(&name, base->buf + tn_len);
640 match = tree_entry_interesting(repo->index,
641 &entry, &name,
642 - 0, pathspec);
642 + pathspec);
643 strbuf_setlen(&name, name_base_len);
644
645 if (match == all_entries_not_interesting)
list-objects.c
+1 -1
@@ -102,7 +102,7 @@ static void process_tree_contents(struct traversal_context *ctx,
102 while (tree_entry(&desc, &entry)) {
103 if (match != all_entries_interesting) {
104 match = tree_entry_interesting(ctx->revs->repo->index,
105 - &entry, base, 0,
105 + &entry, base,
106 &ctx->revs->diffopt.pathspec);
107 if (match == all_entries_not_interesting)
108 break;
tree-diff.c
+1 -1
@@ -316,7 +316,7 @@ static void skip_uninteresting(struct tree_desc *t, struct strbuf *base,
316
317 while (t->size) {
318 match = tree_entry_interesting(opt->repo->index, &t->entry,
319 - base, 0, &opt->pathspec);
319 + base, &opt->pathspec);
320 if (match) {
321 if (match == all_entries_not_interesting)
322 t->size = 0;
tree-walk.c
+3 -2
@@ -435,7 +435,7 @@ static inline int prune_traversal(struct index_state *istate,
435 if (still_interesting < 0)
436 return still_interesting;
437 return tree_entry_interesting(istate, e, base,
438 - 0, info->pathspec);
438 + info->pathspec);
439 }
440
441 int traverse_trees(struct index_state *istate,
@@ -1223,10 +1223,11 @@ interesting:
1223 */
1224 enum interesting tree_entry_interesting(struct index_state *istate,
1225 const struct name_entry *entry,
1226 - struct strbuf *base, int base_offset,
1226 + struct strbuf *base,
1227 const struct pathspec *ps)
1228 {
1229 enum interesting positive, negative;
1230 + const int base_offset = 0;
1231 positive = do_match(istate, entry, base, base_offset, ps, 0);
1232
1233 /*
tree-walk.h
+1 -1
@@ -224,7 +224,7 @@ enum interesting {
224
225 enum interesting tree_entry_interesting(struct index_state *istate,
226 const struct name_entry *,
227 - struct strbuf *, int,
227 + struct strbuf *,
228 const struct pathspec *ps);
229
230 #endif
tree.c
+1 -1
@@ -32,7 +32,7 @@ int read_tree_at(struct repository *r,
32 while (tree_entry(&desc, &entry)) {
33 if (retval != all_entries_interesting) {
34 retval = tree_entry_interesting(r->index, &entry,
35 - base, 0, pathspec);
35 + base, pathspec);
36 if (retval == all_entries_not_interesting)
37 break;
38 if (retval == entry_not_interesting)