git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Stefan Beller <sbeller@google.com>
To: gitster@pobox.com
Cc: git@vger.kernel.org, Jens.Lehmann@web.de,
	Stefan Beller <sbeller@google.com>
Subject: [PATCH] submodule--helper: correct index computation
Date: Wed, 20 Jul 2016 18:39:23 -0700	[thread overview]
Message-ID: <20160721013923.17435-1-sbeller@google.com> (raw)

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@google.com>
---
 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


                 reply	other threads:[~2016-07-21  1:39 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160721013923.17435-1-sbeller@google.com \
    --to=sbeller@google.com \
    --cc=Jens.Lehmann@web.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).