Skip to content

Commit 78ca584

Browse files
jonathantanmygitster
authored andcommitted
grep: read submodule entry with explicit repo
Replace an existing parse_object_or_die() call (which implicitly works on the_repository) with a function call that allows a repository to be passed in. There is no such direct equivalent to parse_object_or_die(), but we only need the type of the object, so replace with oid_object_info(). Signed-off-by: Jonathan Tan <[email protected]> Reviewed-by: Emily Shaffer <[email protected]> Reviewed-by: Matheus Tavares <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 50d92b5 commit 78ca584

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

builtin/grep.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -457,27 +457,27 @@ static int grep_submodule(struct grep_opt *opt,
457457
subopt.repo = &subrepo;
458458

459459
if (oid) {
460-
struct object *object;
460+
enum object_type object_type;
461461
struct tree_desc tree;
462462
void *data;
463463
unsigned long size;
464464
struct strbuf base = STRBUF_INIT;
465465

466466
obj_read_lock();
467-
object = parse_object_or_die(oid, NULL);
467+
object_type = oid_object_info(&subrepo, oid, NULL);
468468
obj_read_unlock();
469469
data = read_object_with_reference(&subrepo,
470-
&object->oid, tree_type,
470+
oid, tree_type,
471471
&size, NULL);
472472
if (!data)
473-
die(_("unable to read tree (%s)"), oid_to_hex(&object->oid));
473+
die(_("unable to read tree (%s)"), oid_to_hex(oid));
474474

475475
strbuf_addstr(&base, filename);
476476
strbuf_addch(&base, '/');
477477

478478
init_tree_desc(&tree, data, size);
479479
hit = grep_tree(&subopt, pathspec, &tree, &base, base.len,
480-
object->type == OBJ_COMMIT);
480+
object_type == OBJ_COMMIT);
481481
strbuf_release(&base);
482482
free(data);
483483
} else {

0 commit comments

Comments
 (0)