grep: use submodule-ODB-as-alternate lazy-addition
In the parent commit, Git was taught to add submodule ODBs as alternates lazily, but grep does not use this because it computes the path to add directly, not going through add_submodule_odb(). Add an equivalent to add_submodule_odb() that takes the exact ODB path and teach grep to use it. Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Reviewed-by: Emily Shaffer <emilyshaffer@google.com> Reviewed-by: Matheus Tavares <matheus.bernardino@usp.br> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jonathan Tan committed
Aug 16, 2021 at 14:09 UTC
8d33c3af0b2113091ea2c2c94990d0332c9551e7
3 files changed
+7
-1
builtin/grep.c
+1
-1
@@ -450,7 +450,7 @@ static int grep_submodule(struct grep_opt *opt,
450
* store is no longer global and instead is a member of the repository
451
* object.
452
*/
453
- add_to_alternates_memory(subrepo.objects->odb->path);
453
+ add_submodule_odb_by_path(subrepo.objects->odb->path);
454
obj_read_unlock();
455
456
memcpy(&subopt, opt, sizeof(subopt));
submodule.c
+5
@@ -187,6 +187,11 @@ done:
187
return ret;
188
}
189
190
+void add_submodule_odb_by_path(const char *path)
191
+{
192
+ string_list_insert(&added_submodule_odb_paths, xstrdup(path));
193
+}
194
+
195
int register_all_submodule_odb_as_alternates(void)
196
{
197
int i;
submodule.h
+1
@@ -104,6 +104,7 @@ int bad_to_remove_submodule(const char *path, unsigned flags);
104
* the_repository.
105
*/
106
int add_submodule_odb(const char *path);
107
+void add_submodule_odb_by_path(const char *path);
108
int register_all_submodule_odb_as_alternates(void);
109
110
/*