push: change needlessly ambiguous example in error
[gitweb.git] / builtin / grep.c
index d8508ddf792dd22dc0c8c283df29e5e6d9dacbf7..56e4a110526379d1df69615a0ade611c2a82c17d 100644 (file)
@@ -422,11 +422,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);
 
@@ -440,7 +452,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();