Skip to content

Commit 8d33c3a

Browse files
jonathantanmygitster
authored andcommitted
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 <[email protected]> Reviewed-by: Emily Shaffer <[email protected]> Reviewed-by: Matheus Tavares <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a35e03d commit 8d33c3a

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

builtin/grep.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ static int grep_submodule(struct grep_opt *opt,
450450
* store is no longer global and instead is a member of the repository
451451
* object.
452452
*/
453-
add_to_alternates_memory(subrepo.objects->odb->path);
453+
add_submodule_odb_by_path(subrepo.objects->odb->path);
454454
obj_read_unlock();
455455

456456
memcpy(&subopt, opt, sizeof(subopt));

submodule.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,11 @@ int add_submodule_odb(const char *path)
187187
return ret;
188188
}
189189

190+
void add_submodule_odb_by_path(const char *path)
191+
{
192+
string_list_insert(&added_submodule_odb_paths, xstrdup(path));
193+
}
194+
190195
int register_all_submodule_odb_as_alternates(void)
191196
{
192197
int i;

submodule.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ int bad_to_remove_submodule(const char *path, unsigned flags);
104104
* the_repository.
105105
*/
106106
int add_submodule_odb(const char *path);
107+
void add_submodule_odb_by_path(const char *path);
107108
int register_all_submodule_odb_as_alternates(void);
108109

109110
/*

0 commit comments

Comments
 (0)