summaryrefslogtreecommitdiff
path: root/submodule-config.c
diff options
context:
space:
mode:
authorJonathan Tan <jonathantanmy@google.com>2021-08-16 21:09:57 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-09-08 18:48:09 (GMT)
commite3e8bf046e9682b0d67c07c6bc83ec9717d9c941 (patch)
tree4f7add2b871f29541679ac0d55b6f10cb4756af4 /submodule-config.c
parent0693806bf82fb76347e226d8fc5e69077c0a3df5 (diff)
downloadgit-e3e8bf046e9682b0d67c07c6bc83ec9717d9c941.zip
git-e3e8bf046e9682b0d67c07c6bc83ec9717d9c941.tar.gz
git-e3e8bf046e9682b0d67c07c6bc83ec9717d9c941.tar.bz2
submodule-config: pass repo upon blob config read
When reading the config of a submodule, if reading from a blob, read using an explicitly specified repository instead of by adding the submodule's ODB as an alternate and then reading an object from the_repository. This makes the "grep --recurse-submodules with submodules without .gitmodules in the working tree" test in t7814 work when GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB is true. Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Reviewed-by: Matheus Tavares <matheus.bernardino@usp.br> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'submodule-config.c')
-rw-r--r--submodule-config.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/submodule-config.c b/submodule-config.c
index 2026120..f953440 100644
--- a/submodule-config.c
+++ b/submodule-config.c
@@ -649,9 +649,10 @@ static void config_from_gitmodules(config_fn_t fn, struct repository *repo, void
config_source.file = file;
} else if (repo_get_oid(repo, GITMODULES_INDEX, &oid) >= 0 ||
repo_get_oid(repo, GITMODULES_HEAD, &oid) >= 0) {
+ config_source.repo = repo;
config_source.blob = oidstr = xstrdup(oid_to_hex(&oid));
if (repo != the_repository)
- add_to_alternates_memory(repo->objects->odb->path);
+ add_submodule_odb_by_path(repo->objects->odb->path);
} else {
goto out;
}
@@ -702,7 +703,7 @@ void gitmodules_config_oid(const struct object_id *commit_oid)
if (gitmodule_oid_from_commit(commit_oid, &oid, &rev)) {
git_config_from_blob_oid(gitmodules_cb, rev.buf,
- &oid, the_repository);
+ the_repository, &oid, the_repository);
}
strbuf_release(&rev);