summaryrefslogtreecommitdiff
path: root/builtin/grep.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2019-08-22 19:34:10 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-08-22 19:34:10 (GMT)
commit307179732d580735c579b9bfae2eaf7a536f4ae9 (patch)
tree83689a991d1519207c510d0ff6669ffc758b5e3b /builtin/grep.c
parent5fa0f5238b0cd46cfe7f6fa76c3f526ea98148d9 (diff)
parent6a289d45c0e5d155f536d7c1f73c3b33690e92c6 (diff)
downloadgit-307179732d580735c579b9bfae2eaf7a536f4ae9.zip
git-307179732d580735c579b9bfae2eaf7a536f4ae9.tar.gz
git-307179732d580735c579b9bfae2eaf7a536f4ae9.tar.bz2
Merge branch 'mt/grep-submodules-working-tree'
"git grep --recurse-submodules" that looks at the working tree files looked at the contents in the index in submodules, instead of files in the working tree. * mt/grep-submodules-working-tree: grep: fix worktree case in submodules
Diffstat (limited to 'builtin/grep.c')
-rw-r--r--builtin/grep.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/builtin/grep.c b/builtin/grep.c
index 5600517..2699001 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -403,7 +403,7 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,
static int grep_submodule(struct grep_opt *opt,
const struct pathspec *pathspec,
const struct object_id *oid,
- const char *filename, const char *path)
+ const char *filename, const char *path, int cached)
{
struct repository subrepo;
struct repository *superproject = opt->repo;
@@ -475,7 +475,7 @@ static int grep_submodule(struct grep_opt *opt,
strbuf_release(&base);
free(data);
} else {
- hit = grep_cache(&subopt, pathspec, 1);
+ hit = grep_cache(&subopt, pathspec, cached);
}
repo_clear(&subrepo);
@@ -523,7 +523,8 @@ static int grep_cache(struct grep_opt *opt,
}
} else if (recurse_submodules && S_ISGITLINK(ce->ce_mode) &&
submodule_path_match(repo->index, pathspec, name.buf, NULL)) {
- hit |= grep_submodule(opt, pathspec, NULL, ce->name, ce->name);
+ hit |= grep_submodule(opt, pathspec, NULL, ce->name,
+ ce->name, cached);
} else {
continue;
}
@@ -598,7 +599,8 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,
free(data);
} else if (recurse_submodules && S_ISGITLINK(entry.mode)) {
hit |= grep_submodule(opt, pathspec, &entry.oid,
- base->buf, base->buf + tn_len);
+ base->buf, base->buf + tn_len,
+ 1); /* ignored */
}
strbuf_setlen(base, old_baselen);