diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2018-08-13 16:14:22 (GMT) |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-08-13 21:14:42 (GMT) |
commit | 6d2df284e7f4d7cd9f46992282ef59a72a9db527 (patch) | |
tree | e574b2e2c62144926ced7a251f82260a61211d16 /builtin/grep.c | |
parent | 7f944e264ebe2fcf9a2c228a9fc9463ab3274d39 (diff) | |
download | git-6d2df284e7f4d7cd9f46992282ef59a72a9db527.zip git-6d2df284e7f4d7cd9f46992282ef59a72a9db527.tar.gz git-6d2df284e7f4d7cd9f46992282ef59a72a9db527.tar.bz2 |
dir.c: remove an implicit dependency on the_index in pathspec code
Make the match_patchspec API and friends take an index_state instead
of assuming the_index in dir.c. All external call sites are converted
blindly to keep the patch simple and retain current behavior.
Individual call sites may receive further updates to use the right
index instead of the_index.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/grep.c')
-rw-r--r-- | builtin/grep.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/builtin/grep.c b/builtin/grep.c index 056161f..9d7ba87 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -497,7 +497,7 @@ static int grep_cache(struct grep_opt *opt, struct repository *repo, strbuf_addstr(&name, ce->name); if (S_ISREG(ce->ce_mode) && - match_pathspec(pathspec, name.buf, name.len, 0, NULL, + match_pathspec(&the_index, pathspec, name.buf, name.len, 0, NULL, S_ISDIR(ce->ce_mode) || S_ISGITLINK(ce->ce_mode))) { /* @@ -515,7 +515,7 @@ static int grep_cache(struct grep_opt *opt, struct repository *repo, hit |= grep_file(opt, name.buf); } } else if (recurse_submodules && S_ISGITLINK(ce->ce_mode) && - submodule_path_match(pathspec, name.buf, NULL)) { + submodule_path_match(&the_index, pathspec, name.buf, NULL)) { hit |= grep_submodule(opt, repo, pathspec, NULL, ce->name, ce->name); } else { continue; @@ -679,7 +679,7 @@ static int grep_directory(struct grep_opt *opt, const struct pathspec *pathspec, fill_directory(&dir, &the_index, pathspec); for (i = 0; i < dir.nr; i++) { - if (!dir_path_match(dir.entries[i], pathspec, 0, NULL)) + if (!dir_path_match(&the_index, dir.entries[i], pathspec, 0, NULL)) continue; hit |= grep_file(opt, dir.entries[i]->name); if (hit && opt->status_only) |