summaryrefslogtreecommitdiff
path: root/builtin/grep.c
diff options
context:
space:
mode:
Diffstat (limited to 'builtin/grep.c')
-rw-r--r--builtin/grep.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/builtin/grep.c b/builtin/grep.c
index 601f801158..7da8fef31a 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -421,11 +421,23 @@ static int grep_submodule(struct grep_opt *opt, struct repository *superproject,
struct repository submodule;
int hit;
- if (!is_submodule_active(superproject, path))
+ /*
+ * NEEDSWORK: submodules functions need to be protected because they
+ * access the object store via config_from_gitmodules(): the latter
+ * uses get_oid() which, for now, relies on the global the_repository
+ * object.
+ */
+ grep_read_lock();
+
+ if (!is_submodule_active(superproject, path)) {
+ grep_read_unlock();
return 0;
+ }
- if (repo_submodule_init(&submodule, superproject, path))
+ if (repo_submodule_init(&submodule, superproject, path)) {
+ grep_read_unlock();
return 0;
+ }
repo_read_gitmodules(&submodule);
@@ -439,7 +451,6 @@ 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.
*/
- grep_read_lock();
add_to_alternates_memory(submodule.objects->objectdir);
grep_read_unlock();