summaryrefslogtreecommitdiff
path: root/submodule.h
diff options
context:
space:
mode:
authorJonathan Tan <jonathantanmy@google.com>2021-08-16 21:09:51 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-09-08 18:47:36 (GMT)
commita35e03dee0e8daa442227018ecd180ae1c1b39bc (patch)
tree858b7c974141a62c73222b6e758837a202738681 /submodule.h
parent2d755dfac9aadab25c3e025b849252b8c0a61465 (diff)
downloadgit-a35e03dee0e8daa442227018ecd180ae1c1b39bc.zip
git-a35e03dee0e8daa442227018ecd180ae1c1b39bc.tar.gz
git-a35e03dee0e8daa442227018ecd180ae1c1b39bc.tar.bz2
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>
Diffstat (limited to 'submodule.h')
-rw-r--r--submodule.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/submodule.h b/submodule.h
index 84640c4..c252784 100644
--- a/submodule.h
+++ b/submodule.h
@@ -97,7 +97,14 @@ int submodule_uses_gitfile(const char *path);
#define SUBMODULE_REMOVAL_IGNORE_IGNORED_UNTRACKED (1<<2)
int bad_to_remove_submodule(const char *path, unsigned flags);
+/*
+ * Call add_submodule_odb() to add the submodule at the given path to a list.
+ * When register_all_submodule_odb_as_alternates() is called, the object stores
+ * of all submodules in that list will be added as alternates in
+ * the_repository.
+ */
int add_submodule_odb(const char *path);
+int register_all_submodule_odb_as_alternates(void);
/*
* Checks if there are submodule changes in a..b. If a is the null OID,