@matheusbsbs / matheus-bagliano / commits / 7655b4119d
Fork 0

remote-curl: show progress for fetches over dumb HTTP

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>

René Scharfe committed Mar 3, 2020 at 21:55 UTC 7655b4119d49844e6ebc62da571e5f18528dbde8
3 files changed +14 -1
remote-curl.c
+1
@@ -1026,6 +1026,7 @@ static int fetch_dumb(int nr_heads, struct ref **to_fetch)
1026
1027 walker = get_http_walker(url.buf);
1028 walker->get_verbosely = options.verbosity >= 3;
1029 + walker->get_progress = options.progress;
1030 walker->get_recover = 0;
1031 ret = walker_fetch(walker, nr_heads, targets, NULL, NULL);
1032 walker_free(walker);
walker.c
+12 -1
@@ -8,6 +8,7 @@
8 #include "tag.h"
9 #include "blob.h"
10 #include "refs.h"
11 +#include "progress.h"
12
13 static struct object_id current_commit_oid;
14
@@ -162,6 +163,11 @@ static int process(struct walker *walker, struct object *obj)
163 static int loop(struct walker *walker)
164 {
165 struct object_list *elem;
166 + struct progress *progress = NULL;
167 + uint64_t nr = 0;
168 +
169 + if (walker->get_progress)
170 + progress = start_delayed_progress(_("Fetching objects"), 0);
171
172 while (process_queue) {
173 struct object *obj = process_queue->item;
@@ -176,15 +182,20 @@ static int loop(struct walker *walker)
182 */
183 if (! (obj->flags & TO_SCAN)) {
184 if (walker->fetch(walker, obj->oid.hash)) {
185 + stop_progress(&progress);
186 report_missing(obj);
187 return -1;
188 }
189 }
190 if (!obj->type)
191 parse_object(the_repository, &obj->oid);
185 - if (process_object(walker, obj))
192 + if (process_object(walker, obj)) {
193 + stop_progress(&progress);
194 return -1;
195 + }
196 + display_progress(progress, ++nr);
197 }
198 + stop_progress(&progress);
199 return 0;
200 }
201
walker.h
+1
@@ -10,6 +10,7 @@ struct walker {
10 int (*fetch)(struct walker *, unsigned char *sha1);
11 void (*cleanup)(struct walker *);
12 int get_verbosely;
13 + int get_progress;
14 int get_recover;
15
16 int corrupt_object_found;