In 665b35eccd39 (2016-06-09, submodule--helper: initial clone learns retry logic), the index computation for the second round is wrong; it should make use of the index that was handed in via the idx_task_cb pointer. When that commit was introduced, I wrote: > I wonder how we can test this properly as the git binary we have here > is too reliable, but I observed the correctness of this patch when > cloning a repo with lots of submodules and one of them failing. This was only partially true as I did not observe the second try failing, only the first retry succeeding. Testing however is really easy, when the url of one submodule is bogus, so add a test for that. Signed-off-by: Stefan Beller <sbeller@xxxxxxxxxx> --- builtin/submodule--helper.c | 4 +++- t/t7406-submodule-update.sh | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 494e088..5d54885 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -795,7 +795,9 @@ static int update_clone_task_finished(int result, suc->failed_clones[suc->failed_clones_nr++] = ce; return 0; } else { - idx = suc->current - suc->list.nr; + idx -= suc->list.nr; + if (idx >= suc->failed_clones_nr) + die("BUG: idx too large???"); ce = suc->failed_clones[idx]; strbuf_addf(err, _("Failed to clone '%s' a second time, aborting"), ce->name); diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh index 88e9750..ffb329f 100755 --- a/t/t7406-submodule-update.sh +++ b/t/t7406-submodule-update.sh @@ -889,4 +889,20 @@ test_expect_success 'git clone passes the parallel jobs config on to submodules' rm -rf super4 ' +cat << EOF >expect +Submodule 'deeper/submodule' (bogus-url) registered for path 'deeper/submodule' +fatal: clone of 'bogus-url' into submodule path '$pwd/super4/deeper/submodule' failed +Failed to clone 'deeper/submodule'. Retry scheduled +fatal: clone of 'bogus-url' into submodule path '$pwd/super4/deeper/submodule' failed +Failed to clone 'deeper/submodule' a second time, aborting +EOF + +test_expect_success 'correct message for retries' ' + test_when_finished "rm -rf super4" && + git -C super config -f .gitmodules submodule."deeper/submodule".url bogus-url && + git -C super commit -a -m "bogus url for one submodule" && + test_must_fail git clone --recurse-submodules -j 1 super super4 2>&1 | grep deeper >actual && + test_cmp expect actual +' + test_done -- 2.9.2.370.g4a59376.dirty -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html