X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin%2Fgrep.c;h=3ee2ec51def59695813ee14f104d142a62d530b6;hb=1c2ef66f63e60539044d1e0cd8fbfbccd2cefc2e;hp=10a1f65310f28f2014bab3f3295205abf6dc59ad;hpb=2db8926236406a4e4cb17d1b9c4b791706fb0512;p=git.git diff --git a/builtin/grep.c b/builtin/grep.c index 10a1f6531..3ee2ec51d 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -533,18 +533,18 @@ static int grep_cache(struct grep_opt *opt, const struct pathspec *pathspec, int static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec, struct tree_desc *tree, struct strbuf *base, int tn_len) { - int hit = 0, matched = 0; + int hit = 0, match = 0; struct name_entry entry; int old_baselen = base->len; while (tree_entry(tree, &entry)) { int te_len = tree_entry_len(entry.path, entry.sha1); - if (matched != 2) { - matched = tree_entry_interesting(&entry, base, tn_len, pathspec); - if (matched == -1) - break; /* no more matches */ - if (!matched) + if (match != 2) { + match = tree_entry_interesting(&entry, base, tn_len, pathspec); + if (match < 0) + break; + if (match == 0) continue; }