aboutsummaryrefslogtreecommitdiffstats
path: root/odb.h
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2025-07-01 14:22:23 +0200
committerJunio C Hamano <gitster@pobox.com>2025-07-01 14:46:37 -0700
commitfc28a8a856a1e7978794e7dee61c42d7d5740a6b (patch)
treed86bf61bdd4f201cb86998393087359b24fb5035 /odb.h
parentodb: get rid of `the_repository` when handling the primary source (diff)
downloadgit-fc28a8a856a1e7978794e7dee61c42d7d5740a6b.tar.gz
git-fc28a8a856a1e7978794e7dee61c42d7d5740a6b.zip
odb: get rid of `the_repository` when handling submodule sources
The "--recursive" flag for git-grep(1) allows users to grep for a string across submodule boundaries. To make this work we add each submodule's object sources to our own object database so that the objects can be accessed directly. The infrastructure for this depends on a global string list of submodule paths. The caller is expected to call `add_submodule_odb_by_path()` for each source and the object database will then eventually register all submodule sources via `do_oid_object_info_extended()` in case it isn't able to look up a specific object. This reliance on global state is of course suboptimal with regards to our libification efforts. Refactor the logic so that the list of submodule sources is instead tracked in the object database itself. This allows us to lose the condition of `r == the_repository` before registering submodule sources as we only ever add submodule sources to `the_repository` anyway. As such, behaviour before and after this refactoring should always be the same. Rename the functions accordingly. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'odb.h')
-rw-r--r--odb.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/odb.h b/odb.h
index 4e2d1004f8..0ea9d4faa7 100644
--- a/odb.h
+++ b/odb.h
@@ -6,6 +6,7 @@
#include "list.h"
#include "oidset.h"
#include "oidmap.h"
+#include "string-list.h"
#include "thread-utils.h"
struct oidmap;
@@ -165,6 +166,12 @@ struct object_database {
* packs.
*/
unsigned packed_git_initialized : 1;
+
+ /*
+ * Submodule source paths that will be added as additional sources to
+ * allow lookup of submodule objects via the main object database.
+ */
+ struct string_list submodule_source_paths;
};
struct object_database *odb_new(struct repository *repo);
@@ -192,6 +199,14 @@ void odb_restore_primary_source(struct object_database *odb,
const char *old_path);
/*
+ * Call odb_add_submodule_source_by_path() to add the submodule at the given
+ * path to a list. The object stores of all submodules in that list will be
+ * added as additional sources in the object store when looking up objects.
+ */
+void odb_add_submodule_source_by_path(struct object_database *odb,
+ const char *path);
+
+/*
* Iterate through all alternates of the database and execute the provided
* callback function for each of them. Stop iterating once the callback
* function returns a non-zero value, in which case the value is bubbled up