]> git.ipfire.org Git - thirdparty/git.git/commitdiff
fetch: emphasize failure during submodule fetch
authorEmily Shaffer <emilyshaffer@google.com>
Thu, 16 Jan 2020 22:20:12 +0000 (14:20 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 17 Jan 2020 20:05:58 +0000 (12:05 -0800)
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>
submodule.c

index 9da7181321f089e8450ec7e39692f7928f5638a8..ee74acee279b0468c0a28805abfd6f3285f2a282 100644 (file)
@@ -1280,10 +1280,12 @@ 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;
 };
 #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}
 
 static int get_fetch_recurse_config(const struct submodule *submodule,
                                    struct submodule_parallel_fetch *spf)
@@ -1547,7 +1549,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 +1562,9 @@ static int fetch_finish(int retvalue, struct strbuf *err,
                 */
                spf->result = 1;
 
-       if (!task || !task->sub)
-               BUG("callback cookie bogus");
+               strbuf_addf(&spf->submodules_with_errors, "\t%s\n",
+                           task->sub->name);
+       }
 
        /* Is this the second time we process this submodule? */
        if (task->commits)
@@ -1627,6 +1633,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);