Re: [PATCH v4 5/6] grep: enable recurse-submodules to work on <tree> objects
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Nov 18, 2016, 22:19 UTC
- Message-ID
- <xmqqh974l9bz.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <1479499135-64269-6-git-send-email-bmwill@google.com>
Brandon Williams <bmwill@google.com> writes:
Show 23 quoted lines
> @@ -671,12 +707,29 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,
> enum interesting match = entry_not_interesting;
> struct name_entry entry;
> int old_baselen = base->len;
> + struct strbuf name = STRBUF_INIT;
> + int name_base_len = 0;
> + if (super_prefix) {
> + strbuf_addstr(&name, super_prefix);
> + name_base_len = name.len;
> + }
>
> while (tree_entry(tree, &entry)) {
> int te_len = tree_entry_len(&entry);
>
> if (match != all_entries_interesting) {
> - match = tree_entry_interesting(&entry, base, tn_len, pathspec);
> + strbuf_setlen(&name, name_base_len);
> + strbuf_addstr(&name, base->buf + tn_len);
> +
> + if (recurse_submodules && S_ISGITLINK(entry.mode)) {
> + strbuf_addstr(&name, entry.path);
> + match = submodule_path_match(pathspec, name.buf,
> + NULL);The vocabulary from submodule_path_match() returns is the same as that of do_match_pathspec() and match_pathspec_item() which is MATCHED_{EXACTLY,FNMATCH,RECURSIVELY}, which is different from the vocabulary of the variable "match" which is "enum interesting" that is used by the tree-walk infrastructure.
I doubt they are compatible to be usable like this. Am I missing something?
Show 8 quoted lines
> + } else {
> + match = tree_entry_interesting(&entry, &name,
> + 0, pathspec);
> + }
> +
> if (match == all_entries_not_interesting)
> break;
> if (match == entry_not_interesting)