summaryrefslogtreecommitdiff
path: root/builtin/grep.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2019-01-29 20:47:54 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-01-29 20:47:54 (GMT)
commit5d3635db19c6dff4fb063fabfa4161fd3b8285f0 (patch)
tree30671c79e96d06267eda7d088a4ef7fd86c3ad47 /builtin/grep.c
parentf33989464ecfc05a937328430b7e74819f7285dd (diff)
parentbe76c2128234d94b47f7087152ee55d08bb65d88 (diff)
downloadgit-5d3635db19c6dff4fb063fabfa4161fd3b8285f0.zip
git-5d3635db19c6dff4fb063fabfa4161fd3b8285f0.tar.gz
git-5d3635db19c6dff4fb063fabfa4161fd3b8285f0.tar.bz2
Merge branch 'sb/submodule-recursive-fetch-gets-the-tip'
"git fetch --recurse-submodules" may not fetch the necessary commit that is bound to the superproject, which is getting corrected. * sb/submodule-recursive-fetch-gets-the-tip: fetch: ensure submodule objects fetched submodule.c: fetch in submodules git directory instead of in worktree submodule: migrate get_next_submodule to use repository structs repository: repo_submodule_init to take a submodule struct submodule: store OIDs in changed_submodule_names submodule.c: tighten scope of changed_submodule_names struct submodule.c: sort changed_submodule_names before searching it submodule.c: fix indentation sha1-array: provide oid_array_filter
Diffstat (limited to 'builtin/grep.c')
-rw-r--r--builtin/grep.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/builtin/grep.c b/builtin/grep.c
index 4748195..dc91838 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -404,7 +404,10 @@ static int grep_submodule(struct grep_opt *opt, struct repository *superproject,
const struct object_id *oid,
const char *filename, const char *path)
{
- struct repository submodule;
+ struct repository subrepo;
+ const struct submodule *sub = submodule_from_path(superproject,
+ &null_oid, path);
+
int hit;
/*
@@ -420,12 +423,12 @@ static int grep_submodule(struct grep_opt *opt, struct repository *superproject,
return 0;
}
- if (repo_submodule_init(&submodule, superproject, path)) {
+ if (repo_submodule_init(&subrepo, superproject, sub)) {
grep_read_unlock();
return 0;
}
- repo_read_gitmodules(&submodule);
+ repo_read_gitmodules(&subrepo);
/*
* NEEDSWORK: This adds the submodule's object directory to the list of
@@ -437,7 +440,7 @@ static int grep_submodule(struct grep_opt *opt, struct repository *superproject,
* store is no longer global and instead is a member of the repository
* object.
*/
- add_to_alternates_memory(submodule.objects->odb->path);
+ add_to_alternates_memory(subrepo.objects->odb->path);
grep_read_unlock();
if (oid) {
@@ -462,14 +465,14 @@ static int grep_submodule(struct grep_opt *opt, struct repository *superproject,
init_tree_desc(&tree, data, size);
hit = grep_tree(opt, pathspec, &tree, &base, base.len,
- object->type == OBJ_COMMIT, &submodule);
+ object->type == OBJ_COMMIT, &subrepo);
strbuf_release(&base);
free(data);
} else {
- hit = grep_cache(opt, &submodule, pathspec, 1);
+ hit = grep_cache(opt, &subrepo, pathspec, 1);
}
- repo_clear(&submodule);
+ repo_clear(&subrepo);
return hit;
}