Skip to content

Commit 0222540

Browse files
nasamuffingitster
authored andcommitted
fetch: emphasize failure during submodule fetch
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. Because fetch_finish() is only called synchronously by run_processes_parallel, mutexing is not required around submodules_with_errors. Signed-off-by: Emily Shaffer <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d0654dc commit 0222540

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

submodule.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,10 +1280,12 @@ struct submodule_parallel_fetch {
12801280
/* Pending fetches by OIDs */
12811281
struct fetch_task **oid_fetch_tasks;
12821282
int oid_fetch_tasks_nr, oid_fetch_tasks_alloc;
1283+
1284+
struct strbuf submodules_with_errors;
12831285
};
12841286
#define SPF_INIT {0, ARGV_ARRAY_INIT, NULL, NULL, 0, 0, 0, 0, \
12851287
STRING_LIST_INIT_DUP, \
1286-
NULL, 0, 0}
1288+
NULL, 0, 0, STRBUF_INIT}
12871289

12881290
static int get_fetch_recurse_config(const struct submodule *submodule,
12891291
struct submodule_parallel_fetch *spf)
@@ -1547,7 +1549,10 @@ static int fetch_finish(int retvalue, struct strbuf *err,
15471549
struct string_list_item *it;
15481550
struct oid_array *commits;
15491551

1550-
if (retvalue)
1552+
if (!task || !task->sub)
1553+
BUG("callback cookie bogus");
1554+
1555+
if (retvalue) {
15511556
/*
15521557
* NEEDSWORK: This indicates that the overall fetch
15531558
* failed, even though there may be a subsequent fetch
@@ -1557,8 +1562,9 @@ static int fetch_finish(int retvalue, struct strbuf *err,
15571562
*/
15581563
spf->result = 1;
15591564

1560-
if (!task || !task->sub)
1561-
BUG("callback cookie bogus");
1565+
strbuf_addf(&spf->submodules_with_errors, "\t%s\n",
1566+
task->sub->name);
1567+
}
15621568

15631569
/* Is this the second time we process this submodule? */
15641570
if (task->commits)
@@ -1627,6 +1633,11 @@ int fetch_populated_submodules(struct repository *r,
16271633
&spf,
16281634
"submodule", "parallel/fetch");
16291635

1636+
if (spf.submodules_with_errors.len > 0)
1637+
fprintf(stderr, _("Errors during submodule fetch:\n%s"),
1638+
spf.submodules_with_errors.buf);
1639+
1640+
16301641
argv_array_clear(&spf.args);
16311642
out:
16321643
free_submodules_oids(&spf.changed_submodule_names);

0 commit comments

Comments
 (0)