* 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. */
| 782 | * working directory. |
| 783 | */ |
| 784 | static 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 | |
| 810 | out: |
| 811 | free(oidstr); |
| 812 | free(file); |
| 813 | } |
| 814 | } |
| 815 | |
| 816 | static int gitmodules_cb(const char *var, const char *value, |
| 817 | const struct config_context *ctx, void *data) |
no test coverage detected