Skip to content

Commit bae60ba

Browse files
szedergitster
authored andcommitted
builtin/unpack-objects.c: show throughput progress
'git unpack-objects' shows a progress line only counting the number of unpacked objects, so if some of the received objects are unusually large, then that progress might appear to be frozen while processing such a larger object. I just stared at a seemingly stuck progress line for over half a minute, while 'git fetch' was busy receiving a pack with only a couple of objects (i.e. fewer than 'fetch.unpackLimit'), with one of them being over 80MB. Display throughput in 'git unpack-objects' progress line, so we show that something is going on even when receiving and processing a large object. Counting the consumed bytes is far away from the place that counts objects and displays progress, and to pass around the 'struct progress' instance we would have to modify the signature of five functions and 14 of their callsites: this is just too much churn, so let's rather make it file-scope static. 'git index-pack', i.e. the non-unpacking cousin of 'git unpack-objects' already includes throughput in its progress line, and it uses a file-scope static 'struct progress' instance as well. Signed-off-by: SZEDER Gábor <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5fa0f52 commit bae60ba

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

builtin/unpack-objects.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ static off_t consumed_bytes;
2424
static off_t max_input_size;
2525
static git_hash_ctx ctx;
2626
static struct fsck_options fsck_options = FSCK_OPTIONS_STRICT;
27+
static struct progress *progress;
2728

2829
/*
2930
* When running under --strict mode, objects whose reachability are
@@ -92,6 +93,7 @@ static void use(int bytes)
9293
consumed_bytes += bytes;
9394
if (max_input_size && consumed_bytes > max_input_size)
9495
die(_("pack exceeds maximum allowed size"));
96+
display_throughput(progress, consumed_bytes);
9597
}
9698

9799
static void *get_data(unsigned long size)
@@ -484,7 +486,6 @@ static void unpack_one(unsigned nr)
484486
static void unpack_all(void)
485487
{
486488
int i;
487-
struct progress *progress = NULL;
488489
struct pack_header *hdr = fill(sizeof(struct pack_header));
489490

490491
nr_objects = ntohl(hdr->hdr_entries);

0 commit comments

Comments
 (0)