summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builtin/grep.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/builtin/grep.c b/builtin/grep.c
index 50ce8d9461..896e7effce 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -407,8 +407,7 @@ static int grep_submodule(struct grep_opt *opt,
{
struct repository subrepo;
struct repository *superproject = opt->repo;
- const struct submodule *sub = submodule_from_path(superproject,
- &null_oid, path);
+ const struct submodule *sub;
struct grep_opt subopt;
int hit;
@@ -419,6 +418,7 @@ static int grep_submodule(struct grep_opt *opt,
* object.
*/
grep_read_lock();
+ sub = submodule_from_path(superproject, &null_oid, path);
if (!is_submodule_active(superproject, path)) {
grep_read_unlock();
@@ -455,9 +455,8 @@ static int grep_submodule(struct grep_opt *opt,
unsigned long size;
struct strbuf base = STRBUF_INIT;
- object = parse_object_or_die(oid, oid_to_hex(oid));
-
grep_read_lock();
+ object = parse_object_or_die(oid, oid_to_hex(oid));
data = read_object_with_reference(&subrepo,
&object->oid, tree_type,
&size, NULL);