{"thread":{"id":"27665","subject":"[PATCH maint] fetch: Also fetch submodules in subdirectories in on-demand mode","startedAt":"2011-06-20T18:18:03Z","lastAt":"2011-06-20T18:18:03Z","messageCount":1,"participants":["Jens Lehmann"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"170312","messageId":"4DFF8EDB.2040502@web.de","threadId":"27665","inReplyTo":null,"subject":"[PATCH maint] fetch: Also fetch submodules in subdirectories in on-demand mode","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2011-06-20T18:18:03Z","receivedAt":"2011-06-20T18:18:03Z","isPatch":true,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"When on-demand mode was active examining the new commits just fetched in\nthe superproject (to check if they record commits for submodules which are\nnot downloaded yet) wasn't done recursively. Because of that fetch did not\nrecursively fetch submodules living in subdirectories even when it should\nhave.\n\nFix that by adding the RECURSIVE flag to the diff_options used to check\nthe new commits and avoid future regressions in this area by moving a\nsubmodule in t5526 into a subdirectory.\n\nSigned-off-by: Jens Lehmann <Jens.Lehmann@web.de>\n---\n\nI found this bug after investigating a rather surprising \"commits not\npresent\" message at work today. I suspect most submodules live in the\ntop level directory of their superproject ...\n\n\n submodule.c                 |    1 +\n t/t5526-fetch-submodules.sh |   16 ++++++++--------\n 2 files changed, 9 insertions(+), 8 deletions(-)\n\ndiff --git a/submodule.c b/submodule.c\nindex 5294cef..e43f221 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -362,6 +362,7 @@ void check_for_new_submodule_commits(unsigned char new_sha1[20])\n \t\twhile (parent) {\n \t\t\tstruct diff_options diff_opts;\n \t\t\tdiff_setup(&diff_opts);\n+\t\t\tDIFF_OPT_SET(&diff_opts, RECURSIVE);\n \t\t\tdiff_opts.output_format |= DIFF_FORMAT_CALLBACK;\n \t\t\tdiff_opts.format_callback = submodule_collect_changed_cb;\n \t\t\tif (diff_setup_done(&diff_opts) < 0)\ndiff --git a/t/t5526-fetch-submodules.sh b/t/t5526-fetch-submodules.sh\nindex a1fddd4..ca5b027 100755\n--- a/t/t5526-fetch-submodules.sh\n+++ b/t/t5526-fetch-submodules.sh\n@@ -47,7 +47,7 @@ test_expect_success setup '\n \t\tgit init &&\n \t\techo subcontent > subfile &&\n \t\tgit add subfile &&\n-\t\tgit submodule add \"$pwd/deepsubmodule\" deepsubmodule &&\n+\t\tgit submodule add \"$pwd/deepsubmodule\" subdir/deepsubmodule &&\n \t\tgit commit -a -m new\n \t) &&\n \tgit submodule add \"$pwd/submodule\" submodule &&\n@@ -58,7 +58,7 @@ test_expect_success setup '\n \t\tgit submodule update --init --recursive\n \t) &&\n \techo \"Fetching submodule submodule\" > expect.out &&\n-\techo \"Fetching submodule submodule/deepsubmodule\" >> expect.out\n+\techo \"Fetching submodule submodule/subdir/deepsubmodule\" >> expect.out\n '\n\n test_expect_success \"fetch --recurse-submodules recurses into submodules\" '\n@@ -277,12 +277,12 @@ test_expect_success \"Recursion picks up all submodules when necessary\" '\n \t(\n \t\tcd submodule &&\n \t\t(\n-\t\t\tcd deepsubmodule &&\n+\t\t\tcd subdir/deepsubmodule &&\n \t\t\tgit fetch &&\n \t\t\tgit checkout -q FETCH_HEAD\n \t\t) &&\n \t\thead1=$(git rev-parse --short HEAD^) &&\n-\t\tgit add deepsubmodule &&\n+\t\tgit add subdir/deepsubmodule &&\n \t\tgit commit -m \"new deepsubmodule\"\n \t\thead2=$(git rev-parse --short HEAD) &&\n \t\techo \"From $pwd/submodule\" > ../expect.err.sub &&\n@@ -309,12 +309,12 @@ test_expect_success \"'--recurse-submodules=on-demand' doesn't recurse when no ne\n \t(\n \t\tcd submodule &&\n \t\t(\n-\t\t\tcd deepsubmodule &&\n+\t\t\tcd subdir/deepsubmodule &&\n \t\t\tgit fetch &&\n \t\t\tgit checkout -q FETCH_HEAD\n \t\t) &&\n \t\thead1=$(git rev-parse --short HEAD^) &&\n-\t\tgit add deepsubmodule &&\n+\t\tgit add subdir/deepsubmodule &&\n \t\tgit commit -m \"new deepsubmodule\"\n \t\thead2=$(git rev-parse --short HEAD) &&\n \t\techo \"From $pwd/submodule\" > ../expect.err.sub &&\n@@ -345,13 +345,13 @@ test_expect_success \"'--recurse-submodules=on-demand' recurses as deep as necess\n \t\tgit config fetch.recurseSubmodules false &&\n \t\t(\n \t\t\tcd submodule &&\n-\t\t\tgit config -f .gitmodules submodule.deepsubmodule.fetchRecursive false\n+\t\t\tgit config -f .gitmodules submodule.subdir/deepsubmodule.fetchRecursive false\n \t\t) &&\n \t\tgit fetch --recurse-submodules=on-demand >../actual.out 2>../actual.err &&\n \t\tgit config --unset fetch.recurseSubmodules\n \t\t(\n \t\t\tcd submodule &&\n-\t\t\tgit config --unset -f .gitmodules submodule.deepsubmodule.fetchRecursive\n+\t\t\tgit config --unset -f .gitmodules submodule.subdir/deepsubmodule.fetchRecursive\n \t\t)\n \t) &&\n \ttest_i18ncmp expect.out actual.out &&\n-- \n1.7.5.4.3.ge9634\n"}]}