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 <emilyshaffer@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Emily Shaffer committed
Jan 16, 2020 at 14:20 UTC
0222540827ae7bf6d7be8612b056f267346beddc
1 file changed
+15
-4
submodule.c
+15
-4
@@ -1280,10 +1280,12 @@ struct submodule_parallel_fetch {
1280
/* Pending fetches by OIDs */
1281
struct fetch_task **oid_fetch_tasks;
1282
int oid_fetch_tasks_nr, oid_fetch_tasks_alloc;
1283
+
1284
+ struct strbuf submodules_with_errors;
1285
};
1286
#define SPF_INIT {0, ARGV_ARRAY_INIT, NULL, NULL, 0, 0, 0, 0, \
1287
STRING_LIST_INIT_DUP, \
1286
- NULL, 0, 0}
1288
+ NULL, 0, 0, STRBUF_INIT}
1289
1290
static int get_fetch_recurse_config(const struct submodule *submodule,
1291
struct submodule_parallel_fetch *spf)
@@ -1547,7 +1549,10 @@ static int fetch_finish(int retvalue, struct strbuf *err,
1549
struct string_list_item *it;
1550
struct oid_array *commits;
1551
1550
- if (retvalue)
1552
+ if (!task || !task->sub)
1553
+ BUG("callback cookie bogus");
1554
+
1555
+ if (retvalue) {
1556
/*
1557
* NEEDSWORK: This indicates that the overall fetch
1558
* failed, even though there may be a subsequent fetch
@@ -1557,8 +1562,9 @@ static int fetch_finish(int retvalue, struct strbuf *err,
1562
*/
1563
spf->result = 1;
1564
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
+ }
1568
1569
/* Is this the second time we process this submodule? */
1570
if (task->commits)
@@ -1627,6 +1633,11 @@ int fetch_populated_submodules(struct repository *r,
1633
&spf,
1634
"submodule", "parallel/fetch");
1635
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
+
1641
argv_array_clear(&spf.args);
1642
out:
1643
free_submodules_oids(&spf.changed_submodule_names);