Git Mailing List Archive on lore.kernel.org
 help / color / Atom feed
From: Emily Shaffer <emilyshaffer@google.com>
To: git@vger.kernel.org
Cc: Emily Shaffer <emilyshaffer@google.com>,
	Junio C Hamano <gitster@pobox.com>
Subject: [PATCH v2] fetch: emphasize failure during submodule fetch
Date: Wed, 15 Jan 2020 18:59:48 -0800
Message-ID: <20200116025948.136479-1-emilyshaffer@google.com> (raw)
In-Reply-To: <20200110195533.6416-1-emilyshaffer@google.com>

In cases when a submodule fetch fails when there are many submodules, the error
from the lone failing submodule fetch is buried under activity on the other
submodules if more than one fetch fell back on fetch-by-oid. Call out a failure
late so the user is aware that something went wrong, and where.

Signed-off-by: Emily Shaffer <emilyshaffer@google.com>
---
V1's approach was to show a generic error based on the output status of
fetch_populated_submodules(); with a long set of submodules, this is
only marginally better than showing the error inline. For v2, instead
we're gathering a list of submodules which failed during the parallel
processing.

The contents of stderr at the time fetch_finish() is called is not
available to us; 'err' on the input is for providing output only. So,
gather the submodule name only.

 - Emily

 submodule.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/submodule.c b/submodule.c
index 9da7181321..13bc9354bc 100644
--- a/submodule.c
+++ b/submodule.c
@@ -1280,10 +1280,13 @@ struct submodule_parallel_fetch {
 	/* Pending fetches by OIDs */
 	struct fetch_task **oid_fetch_tasks;
 	int oid_fetch_tasks_nr, oid_fetch_tasks_alloc;
+
+	struct strbuf submodules_with_errors;
+	pthread_mutex_t submodule_errors_mutex;
 };
 #define SPF_INIT {0, ARGV_ARRAY_INIT, NULL, NULL, 0, 0, 0, 0, \
 		  STRING_LIST_INIT_DUP, \
-		  NULL, 0, 0}
+		  NULL, 0, 0, STRBUF_INIT, PTHREAD_MUTEX_INITIALIZER}
 
 static int get_fetch_recurse_config(const struct submodule *submodule,
 				    struct submodule_parallel_fetch *spf)
@@ -1547,7 +1550,10 @@ static int fetch_finish(int retvalue, struct strbuf *err,
 	struct string_list_item *it;
 	struct oid_array *commits;
 
-	if (retvalue)
+	if (!task || !task->sub)
+		BUG("callback cookie bogus");
+
+	if (retvalue) {
 		/*
 		 * NEEDSWORK: This indicates that the overall fetch
 		 * failed, even though there may be a subsequent fetch
@@ -1557,8 +1563,11 @@ static int fetch_finish(int retvalue, struct strbuf *err,
 		 */
 		spf->result = 1;
 
-	if (!task || !task->sub)
-		BUG("callback cookie bogus");
+		pthread_mutex_lock(&spf->submodule_errors_mutex);
+		strbuf_addf(&spf->submodules_with_errors, "\t%s\n",
+			    task->sub->name);
+		pthread_mutex_unlock(&spf->submodule_errors_mutex);
+	}
 
 	/* Is this the second time we process this submodule? */
 	if (task->commits)
@@ -1627,6 +1636,11 @@ int fetch_populated_submodules(struct repository *r,
 				   &spf,
 				   "submodule", "parallel/fetch");
 
+	if (spf.submodules_with_errors.len > 0)
+		fprintf(stderr, "Errors during submodule fetch:\n%s",
+			spf.submodules_with_errors.buf);
+
+
 	argv_array_clear(&spf.args);
 out:
 	free_submodules_oids(&spf.changed_submodule_names);
-- 
2.25.0.rc1.283.g88dfdc4193-goog


  parent reply index

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-10 19:55 [PATCH] " Emily Shaffer
2020-01-10 20:18 ` Junio C Hamano
2020-01-10 23:01   ` Emily Shaffer
2020-01-16  2:59 ` Emily Shaffer [this message]
2020-01-16 18:23   ` [PATCH v2] " Junio C Hamano
2020-01-16 21:55     ` Emily Shaffer
2020-01-16 22:04       ` Emily Shaffer
2020-01-16 22:20   ` [PATCH v3] " Emily Shaffer
2020-01-17 10:54     ` Johannes Schindelin

Reply instructions:

You may reply publically 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

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

  git send-email \
    --in-reply-to=20200116025948.136479-1-emilyshaffer@google.com \
    --to=emilyshaffer@google.com \
    --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

Git Mailing List Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/git/0 git/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 git git/ https://lore.kernel.org/git \
		git@vger.kernel.org
	public-inbox-index git

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.git


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git