MCPcopy Index your code
hub / github.com/git/git / config_from_gitmodules

Function config_from_gitmodules

submodule-config.c:784–814  ·  view source on GitHub ↗

* Note: This function is private for a reason, the '.gitmodules' file should * not be used as a mechanism to retrieve arbitrary configuration stored in * the repository. * * Runs the provided config function on the '.gitmodules' file found in the * working directory. */

Source from the content-addressed store, hash-verified

782 * working directory.
783 */
784static void config_from_gitmodules(config_fn_t fn, struct repository *repo, void *data)
785{
786 if (repo->worktree) {
787 struct git_config_source config_source = {
788 0, .scope = CONFIG_SCOPE_SUBMODULE
789 };
790 const struct config_options opts = { 0 };
791 struct object_id oid;
792 char *file;
793 char *oidstr = NULL;
794
795 file = repo_worktree_path(repo, GITMODULES_FILE);
796 if (file_exists(file)) {
797 config_source.file = file;
798 } else if (repo_get_oid(repo, GITMODULES_INDEX, &oid) >= 0 ||
799 repo_get_oid(repo, GITMODULES_HEAD, &oid) >= 0) {
800 config_source.blob = oidstr = xstrdup(oid_to_hex(&oid));
801 if (repo != the_repository)
802 odb_add_submodule_source_by_path(the_repository->objects,
803 repo->objects->sources->path);
804 } else {
805 goto out;
806 }
807
808 config_with_options(fn, data, &config_source, repo, &opts);
809
810out:
811 free(oidstr);
812 free(file);
813 }
814}
815
816static int gitmodules_cb(const char *var, const char *value,
817 const struct config_context *ctx, void *data)

Calls 7

repo_worktree_pathFunction · 0.85
file_existsFunction · 0.85
repo_get_oidFunction · 0.85
xstrdupFunction · 0.85
oid_to_hexFunction · 0.85
config_with_optionsFunction · 0.85

Tested by

no test coverage detected