Skip to content

Commit 0ad927e

Browse files
committed
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 <[email protected]>
1 parent fb7d80e commit 0ad927e

File tree

6 files changed

+8
-7
lines changed

6 files changed

+8
-7
lines changed

builtin/grep.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,
639639
strbuf_addstr(&name, base->buf + tn_len);
640640
match = tree_entry_interesting(repo->index,
641641
&entry, &name,
642-
0, pathspec);
642+
pathspec);
643643
strbuf_setlen(&name, name_base_len);
644644

645645
if (match == all_entries_not_interesting)

list-objects.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ static void process_tree_contents(struct traversal_context *ctx,
102102
while (tree_entry(&desc, &entry)) {
103103
if (match != all_entries_interesting) {
104104
match = tree_entry_interesting(ctx->revs->repo->index,
105-
&entry, base, 0,
105+
&entry, base,
106106
&ctx->revs->diffopt.pathspec);
107107
if (match == all_entries_not_interesting)
108108
break;

tree-diff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ static void skip_uninteresting(struct tree_desc *t, struct strbuf *base,
316316

317317
while (t->size) {
318318
match = tree_entry_interesting(opt->repo->index, &t->entry,
319-
base, 0, &opt->pathspec);
319+
base, &opt->pathspec);
320320
if (match) {
321321
if (match == all_entries_not_interesting)
322322
t->size = 0;

tree-walk.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ static inline int prune_traversal(struct index_state *istate,
435435
if (still_interesting < 0)
436436
return still_interesting;
437437
return tree_entry_interesting(istate, e, base,
438-
0, info->pathspec);
438+
info->pathspec);
439439
}
440440

441441
int traverse_trees(struct index_state *istate,
@@ -1223,10 +1223,11 @@ static enum interesting do_match(struct index_state *istate,
12231223
*/
12241224
enum interesting tree_entry_interesting(struct index_state *istate,
12251225
const struct name_entry *entry,
1226-
struct strbuf *base, int base_offset,
1226+
struct strbuf *base,
12271227
const struct pathspec *ps)
12281228
{
12291229
enum interesting positive, negative;
1230+
const int base_offset = 0;
12301231
positive = do_match(istate, entry, base, base_offset, ps, 0);
12311232

12321233
/*

tree-walk.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ enum interesting {
224224

225225
enum interesting tree_entry_interesting(struct index_state *istate,
226226
const struct name_entry *,
227-
struct strbuf *, int,
227+
struct strbuf *,
228228
const struct pathspec *ps);
229229

230230
#endif

tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ int read_tree_at(struct repository *r,
3232
while (tree_entry(&desc, &entry)) {
3333
if (retval != all_entries_interesting) {
3434
retval = tree_entry_interesting(r->index, &entry,
35-
base, 0, pathspec);
35+
base, pathspec);
3636
if (retval == all_entries_not_interesting)
3737
break;
3838
if (retval == entry_not_interesting)

0 commit comments

Comments
 (0)