Skip to content

Commit 6856077

Browse files
jonathantanmygitster
authored andcommitted
grep: remove "repo" arg from non-supporting funcs
As part of commit f9ee2fc ("grep: recurse in-process using 'struct repository'", 2017-08-02), many functions in builtin/grep.c were converted to also take "struct repository *" arguments. Among them were grep_object() and grep_objects(). However, at least grep_objects() was converted incompletely - it calls gitmodules_config_oid(), which references the_repository. But it turns out that the conversion was extraneous anyway - there has been no user-visible effect - because grep_objects() is never invoked except with the_repository. This is because grepping through objects cannot be done recursively into submodules. Revert the changes to grep_objects() and grep_object() (which conversion is also extraneous) to show that both these functions do not support repositories other than the_repository. Signed-off-by: Jonathan Tan <[email protected]> Signed-off-by: Stefan Beller <[email protected]> Reviewed-by: Jonathan Tan <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 61aad92 commit 6856077

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

builtin/grep.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -595,8 +595,7 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,
595595
}
596596

597597
static int grep_object(struct grep_opt *opt, const struct pathspec *pathspec,
598-
struct object *obj, const char *name, const char *path,
599-
struct repository *repo)
598+
struct object *obj, const char *name, const char *path)
600599
{
601600
if (obj->type == OBJ_BLOB)
602601
return grep_oid(opt, &obj->oid, name, 0, path);
@@ -623,7 +622,7 @@ static int grep_object(struct grep_opt *opt, const struct pathspec *pathspec,
623622
}
624623
init_tree_desc(&tree, data, size);
625624
hit = grep_tree(opt, pathspec, &tree, &base, base.len,
626-
obj->type == OBJ_COMMIT, repo);
625+
obj->type == OBJ_COMMIT, the_repository);
627626
strbuf_release(&base);
628627
free(data);
629628
return hit;
@@ -632,7 +631,6 @@ static int grep_object(struct grep_opt *opt, const struct pathspec *pathspec,
632631
}
633632

634633
static int grep_objects(struct grep_opt *opt, const struct pathspec *pathspec,
635-
struct repository *repo,
636634
const struct object_array *list)
637635
{
638636
unsigned int i;
@@ -648,8 +646,8 @@ static int grep_objects(struct grep_opt *opt, const struct pathspec *pathspec,
648646
submodule_free();
649647
gitmodules_config_oid(&real_obj->oid);
650648
}
651-
if (grep_object(opt, pathspec, real_obj, list->objects[i].name, list->objects[i].path,
652-
repo)) {
649+
if (grep_object(opt, pathspec, real_obj, list->objects[i].name,
650+
list->objects[i].path)) {
653651
hit = 1;
654652
if (opt->status_only)
655653
break;
@@ -1098,7 +1096,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
10981096
if (cached)
10991097
die(_("both --cached and trees are given."));
11001098

1101-
hit = grep_objects(&opt, &pathspec, the_repository, &list);
1099+
hit = grep_objects(&opt, &pathspec, &list);
11021100
}
11031101

11041102
if (num_threads)

0 commit comments

Comments
 (0)