This is based on ao/submodule-wo-gitmodules-checked-out. This resends origin/sb/submodule-recursive-fetch-gets-the-tip, resolving the issues pointed out via origin/xxx/sb-submodule-recursive-fetch-gets-the-tip-in-pu by basing this series on origin/ao/submodule-wo-gitmodules-checked-out A range-diff below shows how picking a different base changed the patches, apart from that no further adjustments have been made. Thanks, Stefan Stefan Beller (9): sha1-array: provide oid_array_filter submodule.c: fix indentation submodule.c: sort changed_submodule_names before searching it submodule.c: move global changed_submodule_names into fetch submodule struct submodule.c: do not copy around submodule list repository: repo_submodule_init to take a submodule struct submodule: fetch in submodules git directory instead of in worktree fetch: retry fetching submodules if needed objects were not fetched builtin/fetch: check for submodule updates for non branch fetches Documentation/technical/api-oid-array.txt | 5 + builtin/fetch.c | 14 +- builtin/grep.c | 17 +- builtin/ls-files.c | 12 +- repository.c | 27 +- repository.h | 11 +- sha1-array.c | 17 ++ sha1-array.h | 3 + submodule.c | 275 +++++++++++++++---- t/helper/test-submodule-nested-repo-config.c | 8 +- t/t5526-fetch-submodules.sh | 23 +- 11 files changed, 315 insertions(+), 97 deletions(-) git range-diff origin/xxx/sb-submodule-recursive-fetch-gets-the-tip-in-pu... [...] 585: ac1f98a0df < -: ---------- doc: move git-rev-parse from porcelain to plumbing 586: 7cf1a0fbef = 1: a035323c49 sha1-array: provide oid_array_filter 587: 01077381d0 = 2: 30ed20b4f0 submodule.c: fix indentation 588: 4b0cdf5899 = 3: cd590ea88d submodule.c: sort changed_submodule_names before searching it 589: 78e5099ecc ! 4: ce959811ba submodule.c: move global changed_submodule_names into fetch submodule struct @@ -12,7 +12,7 @@ --- a/submodule.c +++ b/submodule.c @@ - #include "commit-reach.h" + #include "object-store.h" static int config_update_recurse_submodules = RECURSE_SUBMODULES_OFF; -static struct string_list changed_submodule_names = STRING_LIST_INIT_DUP; 590: d813f18bb3 = 5: 151f9a8ad4 submodule.c: do not copy around submodule list 591: a077d63af7 ! 6: 3a97743fa2 repository: repo_submodule_init to take a submodule struct @@ -15,7 +15,6 @@ Also move its documentation into the header file. Signed-off-by: Stefan Beller <sbeller@xxxxxxxxxx> - Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx> diff --git a/builtin/grep.c b/builtin/grep.c --- a/builtin/grep.c @@ -31,12 +30,16 @@ + int hit; - if (!is_submodule_active(superproject, path)) + /* +@@ return 0; + } -- if (repo_submodule_init(&submodule, superproject, path)) -+ if (repo_submodule_init(&subrepo, superproject, sub)) +- if (repo_submodule_init(&submodule, superproject, path)) { ++ if (repo_submodule_init(&subrepo, superproject, sub)) { + grep_read_unlock(); return 0; + } - repo_read_gitmodules(&submodule); + repo_read_gitmodules(&subrepo); @@ -44,9 +47,9 @@ /* * NEEDSWORK: This adds the submodule's object directory to the list of @@ + * store is no longer global and instead is a member of the repository * object. */ - grep_read_lock(); - add_to_alternates_memory(submodule.objects->objectdir); + add_to_alternates_memory(subrepo.objects->objectdir); grep_read_unlock(); @@ -100,19 +103,6 @@ static void show_ce(struct repository *repo, struct dir_struct *dir, -diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c ---- a/builtin/submodule--helper.c -+++ b/builtin/submodule--helper.c -@@ - if (!sub) - BUG("We could get the submodule handle before?"); - -- if (repo_submodule_init(&subrepo, the_repository, path)) -+ if (repo_submodule_init(&subrepo, the_repository, sub)) - die(_("could not get a repository handle for submodule '%s'"), path); - - if (!repo_config_get_string(&subrepo, "core.worktree", &cw)) { - diff --git a/repository.c b/repository.c --- a/repository.c +++ b/repository.c @@ -197,3 +187,32 @@ void repo_clear(struct repository *repo); /* + +diff --git a/t/helper/test-submodule-nested-repo-config.c b/t/helper/test-submodule-nested-repo-config.c +--- a/t/helper/test-submodule-nested-repo-config.c ++++ b/t/helper/test-submodule-nested-repo-config.c +@@ + + int cmd__submodule_nested_repo_config(int argc, const char **argv) + { +- struct repository submodule; ++ struct repository subrepo; ++ const struct submodule *sub; + + if (argc < 3) + die_usage(argc, argv, "Wrong number of arguments."); + + setup_git_directory(); + +- if (repo_submodule_init(&submodule, the_repository, argv[1])) { ++ sub = submodule_from_path(the_repository, &null_oid, argv[1]); ++ if (repo_submodule_init(&subrepo, the_repository, sub)) { + die_usage(argc, argv, "Submodule not found."); + } + + /* Read the config of _child_ submodules. */ +- print_config_from_gitmodules(&submodule, argv[2]); ++ print_config_from_gitmodules(&subrepo, argv[2]); + + submodule_free(the_repository); + 592: 780f6c1a92 = 7: 4e8ad61f8d submodule: fetch in submodules git directory instead of in worktree 593: a530535912 = 8: 24bac00db7 fetch: retry fetching submodules if needed objects were not fetched 594: a72bde3a8a = 9: e031182e44 builtin/fetch: check for submodule updates for non branch fetches [...]