git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] fetch: emphasize failure during submodule fetch

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 16, 2020, 18:23 UTC
Message-ID
<xmqq1rrzi7k1.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20200116025948.136479-1-emilyshaffer@google.com>
Emily Shaffer <emilyshaffer@google.com> writes:
Show 7 quoted lines
> @@ -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;
Hmph, it is kind of surprising that we need a new mutex for this.

Isn't the task_finish handler, which is what accesses the with_errors field this patch adds, called by pp_collect_finished() one at a time, is it?

It seems oid_fetch_tasks[] array is also a shared resource in this structure among the parallel fetch tasks, but there is no protection against simultaneous access to it. Am I missing what makes the new field different? Somewhat puzzled...

Other than that, I think this is a vast improvement relative to the initial round. I wonder if we want to _("i18n/l10n") the message, though.

Thanks.
Show 45 quoted lines
>  #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);
Previous: Emily ShafferNext: Emily Shaffer
Message 5 of 9 in “fetch: emphasize failure during submodule fetch”
  1. fetch: emphasize failure during submodule fetchEmily Shaffer, Jan 10, 2020
  2. Junio C HamanoJan 10, 2020
  3. Emily ShafferJan 10, 2020
  4. fetch: emphasize failure during submodule fetchEmily Shaffer, Jan 16, 2020
  5. Junio C HamanoJan 16, 2020
  6. Emily ShafferJan 16, 2020
  7. Emily ShafferJan 16, 2020
  8. fetch: emphasize failure during submodule fetchEmily Shaffer, Jan 16, 2020
  9. Johannes SchindelinJan 17, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.