]> git.ipfire.org Git - thirdparty/git.git/commit - object-file.c
submodule: lazily add submodule ODBs as alternates
authorJonathan Tan <jonathantanmy@google.com>
Mon, 16 Aug 2021 21:09:51 +0000 (14:09 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 8 Sep 2021 18:47:36 +0000 (11:47 -0700)
commita35e03dee0e8daa442227018ecd180ae1c1b39bc
tree858b7c974141a62c73222b6e758837a202738681
parent2d755dfac9aadab25c3e025b849252b8c0a61465
submodule: lazily add submodule ODBs as alternates

Teach Git to add submodule ODBs as alternates to the object store of
the_repository only upon the first access of an object not in
the_repository, and not when add_submodule_odb() is called.

This provides a means of gradually migrating from accessing a
submodule's object through alternates to accessing a submodule's object
by explicitly passing its repository object. Any Git command can declare
that it might access submodule objects by calling add_submodule_odb()
(as they do now), but the submodule ODBs themselves will not be added
until needed, so individual commands and/or combinations of arguments
can be migrated one by one.

[The advantage of explicit repository-object passing is code clarity (it
is clear which repository an object read is from), performance (there is
no need to linearly search through all submodule ODBs whenever an object
is accessed from any repository, whether superproject or submodule), and
the possibility of future features like partial clone submodules (which
right now is not possible because if an object is missing, we do not
know which repository to lazy-fetch into).]

This commit also introduces an environment variable that a test may set
to make the actual registration of alternates fatal, in order to
demonstrate that its codepaths do not need this registration.

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>
object-file.c
submodule.c
submodule.h
t/README