grep: remove "repo" arg from non-supporting funcs

As part of commit f9ee2fcdfa ("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 <jonathantanmy@google.com> Signed-off-by: Stefan Beller <sbeller@google.com> Reviewed-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Tan committed Mar 28, 2018 at 15:35 UTC 6856077ab063f16b4ccacff971c3ebb185935465
1 file changed +5 -7
builtin/grep.c
+5 -7
@@ -595,8 +595,7 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,
595 }
596
597 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)
599 {
600 if (obj->type == OBJ_BLOB)
601 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,
622 }
623 init_tree_desc(&tree, data, size);
624 hit = grep_tree(opt, pathspec, &tree, &base, base.len,
626 - obj->type == OBJ_COMMIT, repo);
625 + obj->type == OBJ_COMMIT, the_repository);
626 strbuf_release(&base);
627 free(data);
628 return hit;
@@ -632,7 +631,6 @@ static int grep_object(struct grep_opt *opt, const struct pathspec *pathspec,
631 }
632
633 static int grep_objects(struct grep_opt *opt, const struct pathspec *pathspec,
635 - struct repository *repo,
634 const struct object_array *list)
635 {
636 unsigned int i;
@@ -648,8 +646,8 @@ static int grep_objects(struct grep_opt *opt, const struct pathspec *pathspec,
646 submodule_free();
647 gitmodules_config_oid(&real_obj->oid);
648 }
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)) {
651 hit = 1;
652 if (opt->status_only)
653 break;
@@ -1098,7 +1096,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
1096 if (cached)
1097 die(_("both --cached and trees are given."));
1098
1101 - hit = grep_objects(&opt, &pathspec, the_repository, &list);
1099 + hit = grep_objects(&opt, &pathspec, &list);
1100 }
1101
1102 if (num_threads)