]> git.ipfire.org Git - thirdparty/git.git/commitdiff
grep: use submodule-ODB-as-alternate lazy-addition
authorJonathan Tan <jonathantanmy@google.com>
Mon, 16 Aug 2021 21:09:52 +0000 (14:09 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 8 Sep 2021 18:47:49 +0000 (11:47 -0700)
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>
builtin/grep.c
submodule.c
submodule.h

index 7d2f8e5adb69c428847bc23b81bf822c916ccdea..87bcb934a24c341872785b1213b43aa51a1032a4 100644 (file)
@@ -450,7 +450,7 @@ static int grep_submodule(struct grep_opt *opt,
         * store is no longer global and instead is a member of the repository
         * object.
         */
-       add_to_alternates_memory(subrepo.objects->odb->path);
+       add_submodule_odb_by_path(subrepo.objects->odb->path);
        obj_read_unlock();
 
        memcpy(&subopt, opt, sizeof(subopt));
index 8fde90e9063b3a7c86d4725c7528b28fee3b4c5b..8de1aecaeb03113504c59bdfe886afe98e60435e 100644 (file)
@@ -187,6 +187,11 @@ done:
        return ret;
 }
 
+void add_submodule_odb_by_path(const char *path)
+{
+       string_list_insert(&added_submodule_odb_paths, xstrdup(path));
+}
+
 int register_all_submodule_odb_as_alternates(void)
 {
        int i;
index c252784bc2fabe56daa6d8aa43240030192a11d4..17a06cc43bf3d94ac4e5cd4db02c63faab0dd528 100644 (file)
@@ -104,6 +104,7 @@ int bad_to_remove_submodule(const char *path, unsigned flags);
  * the_repository.
  */
 int add_submodule_odb(const char *path);
+void add_submodule_odb_by_path(const char *path);
 int register_all_submodule_odb_as_alternates(void);
 
 /*