Skip to content

Commit 7655b41

Browse files
rscharfegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d0654dc commit 7655b41

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

remote-curl.c

+1
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,7 @@ static int fetch_dumb(int nr_heads, struct ref **to_fetch)
10261026

10271027
walker = get_http_walker(url.buf);
10281028
walker->get_verbosely = options.verbosity >= 3;
1029+
walker->get_progress = options.progress;
10291030
walker->get_recover = 0;
10301031
ret = walker_fetch(walker, nr_heads, targets, NULL, NULL);
10311032
walker_free(walker);

walker.c

+12-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "tag.h"
99
#include "blob.h"
1010
#include "refs.h"
11+
#include "progress.h"
1112

1213
static struct object_id current_commit_oid;
1314

@@ -162,6 +163,11 @@ static int process(struct walker *walker, struct object *obj)
162163
static int loop(struct walker *walker)
163164
{
164165
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);
165171

166172
while (process_queue) {
167173
struct object *obj = process_queue->item;
@@ -176,15 +182,20 @@ static int loop(struct walker *walker)
176182
*/
177183
if (! (obj->flags & TO_SCAN)) {
178184
if (walker->fetch(walker, obj->oid.hash)) {
185+
stop_progress(&progress);
179186
report_missing(obj);
180187
return -1;
181188
}
182189
}
183190
if (!obj->type)
184191
parse_object(the_repository, &obj->oid);
185-
if (process_object(walker, obj))
192+
if (process_object(walker, obj)) {
193+
stop_progress(&progress);
186194
return -1;
195+
}
196+
display_progress(progress, ++nr);
187197
}
198+
stop_progress(&progress);
188199
return 0;
189200
}
190201

walker.h

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ struct walker {
1010
int (*fetch)(struct walker *, unsigned char *sha1);
1111
void (*cleanup)(struct walker *);
1212
int get_verbosely;
13+
int get_progress;
1314
int get_recover;
1415

1516
int corrupt_object_found;

0 commit comments

Comments
 (0)