]> git.ipfire.org Git - thirdparty/git.git/commitdiff
remote-curl: show progress for fetches over dumb HTTP
authorRené Scharfe <l.s.r@web.de>
Tue, 3 Mar 2020 20:55:34 +0000 (21:55 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 3 Mar 2020 21:15:40 +0000 (13:15 -0800)
Fetching over dumb HTTP transport doesn't show any progress, even with
the option --progress.  If the connection is slow or there is a lot of
data to get then this can take a long time while the user is left to
wonder if git got stuck.

We don't know the number of objects to fetch at the outset, but we can
count the ones we got.  Show an open-ended progress indicator based on
that number if the user asked for it.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
remote-curl.c
walker.c
walker.h

index 350d92a074ed82a99060cebb1a4a3fb0a98cfd8e..3ce85b6d5abc1c5c50c5cd0ddcffc87ff9ec011c 100644 (file)
@@ -1026,6 +1026,7 @@ static int fetch_dumb(int nr_heads, struct ref **to_fetch)
 
        walker = get_http_walker(url.buf);
        walker->get_verbosely = options.verbosity >= 3;
+       walker->get_progress = options.progress;
        walker->get_recover = 0;
        ret = walker_fetch(walker, nr_heads, targets, NULL, NULL);
        walker_free(walker);
index 06cd2bd5691a5df247c9b07ca9a4cc3b58ed3912..6a579b230cae04af4db3d1ded4dfa6c5e32c4de9 100644 (file)
--- a/walker.c
+++ b/walker.c
@@ -8,6 +8,7 @@
 #include "tag.h"
 #include "blob.h"
 #include "refs.h"
+#include "progress.h"
 
 static struct object_id current_commit_oid;
 
@@ -162,6 +163,11 @@ static int process(struct walker *walker, struct object *obj)
 static int loop(struct walker *walker)
 {
        struct object_list *elem;
+       struct progress *progress = NULL;
+       uint64_t nr = 0;
+
+       if (walker->get_progress)
+               progress = start_delayed_progress(_("Fetching objects"), 0);
 
        while (process_queue) {
                struct object *obj = process_queue->item;
@@ -176,15 +182,20 @@ static int loop(struct walker *walker)
                 */
                if (! (obj->flags & TO_SCAN)) {
                        if (walker->fetch(walker, obj->oid.hash)) {
+                               stop_progress(&progress);
                                report_missing(obj);
                                return -1;
                        }
                }
                if (!obj->type)
                        parse_object(the_repository, &obj->oid);
-               if (process_object(walker, obj))
+               if (process_object(walker, obj)) {
+                       stop_progress(&progress);
                        return -1;
+               }
+               display_progress(progress, ++nr);
        }
+       stop_progress(&progress);
        return 0;
 }
 
index 6d8ae00e5b995f6565fab8b617e4629788c3c0c7..d40b016bab87980d814571fe8fd96b0f69b495e2 100644 (file)
--- a/walker.h
+++ b/walker.h
@@ -10,6 +10,7 @@ struct walker {
        int (*fetch)(struct walker *, unsigned char *sha1);
        void (*cleanup)(struct walker *);
        int get_verbosely;
+       int get_progress;
        int get_recover;
 
        int corrupt_object_found;