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>
This commit is contained in:
@ -639,7 +639,7 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,
|
|||||||
strbuf_addstr(&name, base->buf + tn_len);
|
strbuf_addstr(&name, base->buf + tn_len);
|
||||||
match = tree_entry_interesting(repo->index,
|
match = tree_entry_interesting(repo->index,
|
||||||
&entry, &name,
|
&entry, &name,
|
||||||
0, pathspec);
|
pathspec);
|
||||||
strbuf_setlen(&name, name_base_len);
|
strbuf_setlen(&name, name_base_len);
|
||||||
|
|
||||||
if (match == all_entries_not_interesting)
|
if (match == all_entries_not_interesting)
|
||||||
|
@ -102,7 +102,7 @@ static void process_tree_contents(struct traversal_context *ctx,
|
|||||||
while (tree_entry(&desc, &entry)) {
|
while (tree_entry(&desc, &entry)) {
|
||||||
if (match != all_entries_interesting) {
|
if (match != all_entries_interesting) {
|
||||||
match = tree_entry_interesting(ctx->revs->repo->index,
|
match = tree_entry_interesting(ctx->revs->repo->index,
|
||||||
&entry, base, 0,
|
&entry, base,
|
||||||
&ctx->revs->diffopt.pathspec);
|
&ctx->revs->diffopt.pathspec);
|
||||||
if (match == all_entries_not_interesting)
|
if (match == all_entries_not_interesting)
|
||||||
break;
|
break;
|
||||||
|
@ -316,7 +316,7 @@ static void skip_uninteresting(struct tree_desc *t, struct strbuf *base,
|
|||||||
|
|
||||||
while (t->size) {
|
while (t->size) {
|
||||||
match = tree_entry_interesting(opt->repo->index, &t->entry,
|
match = tree_entry_interesting(opt->repo->index, &t->entry,
|
||||||
base, 0, &opt->pathspec);
|
base, &opt->pathspec);
|
||||||
if (match) {
|
if (match) {
|
||||||
if (match == all_entries_not_interesting)
|
if (match == all_entries_not_interesting)
|
||||||
t->size = 0;
|
t->size = 0;
|
||||||
|
@ -435,7 +435,7 @@ static inline int prune_traversal(struct index_state *istate,
|
|||||||
if (still_interesting < 0)
|
if (still_interesting < 0)
|
||||||
return still_interesting;
|
return still_interesting;
|
||||||
return tree_entry_interesting(istate, e, base,
|
return tree_entry_interesting(istate, e, base,
|
||||||
0, info->pathspec);
|
info->pathspec);
|
||||||
}
|
}
|
||||||
|
|
||||||
int traverse_trees(struct index_state *istate,
|
int traverse_trees(struct index_state *istate,
|
||||||
@ -1223,10 +1223,11 @@ interesting:
|
|||||||
*/
|
*/
|
||||||
enum interesting tree_entry_interesting(struct index_state *istate,
|
enum interesting tree_entry_interesting(struct index_state *istate,
|
||||||
const struct name_entry *entry,
|
const struct name_entry *entry,
|
||||||
struct strbuf *base, int base_offset,
|
struct strbuf *base,
|
||||||
const struct pathspec *ps)
|
const struct pathspec *ps)
|
||||||
{
|
{
|
||||||
enum interesting positive, negative;
|
enum interesting positive, negative;
|
||||||
|
const int base_offset = 0;
|
||||||
positive = do_match(istate, entry, base, base_offset, ps, 0);
|
positive = do_match(istate, entry, base, base_offset, ps, 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -224,7 +224,7 @@ enum interesting {
|
|||||||
|
|
||||||
enum interesting tree_entry_interesting(struct index_state *istate,
|
enum interesting tree_entry_interesting(struct index_state *istate,
|
||||||
const struct name_entry *,
|
const struct name_entry *,
|
||||||
struct strbuf *, int,
|
struct strbuf *,
|
||||||
const struct pathspec *ps);
|
const struct pathspec *ps);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
2
tree.c
2
tree.c
@ -32,7 +32,7 @@ int read_tree_at(struct repository *r,
|
|||||||
while (tree_entry(&desc, &entry)) {
|
while (tree_entry(&desc, &entry)) {
|
||||||
if (retval != all_entries_interesting) {
|
if (retval != all_entries_interesting) {
|
||||||
retval = tree_entry_interesting(r->index, &entry,
|
retval = tree_entry_interesting(r->index, &entry,
|
||||||
base, 0, pathspec);
|
base, pathspec);
|
||||||
if (retval == all_entries_not_interesting)
|
if (retval == all_entries_not_interesting)
|
||||||
break;
|
break;
|
||||||
if (retval == entry_not_interesting)
|
if (retval == entry_not_interesting)
|
||||||
|
Reference in New Issue
Block a user