pack-objects eye-candy: finishing touches.
This updates the progress output to match "every one second or every percent whichever comes early" used by unpack-objects, as discussed on the list. Signed-off-by: Junio C Hamano <junkio@cox.net>maint
parent
5e8dc750ee
commit
183bdb2ccc
|
@ -324,11 +324,19 @@ static void write_pack_file(void)
|
||||||
struct sha1file *f;
|
struct sha1file *f;
|
||||||
unsigned long offset;
|
unsigned long offset;
|
||||||
struct pack_header hdr;
|
struct pack_header hdr;
|
||||||
|
unsigned last_percent = 999;
|
||||||
|
int do_progress = 0;
|
||||||
|
|
||||||
if (!base_name)
|
if (!base_name)
|
||||||
f = sha1fd(1, "<stdout>");
|
f = sha1fd(1, "<stdout>");
|
||||||
else
|
else {
|
||||||
f = sha1create("%s-%s.%s", base_name, sha1_to_hex(object_list_sha1), "pack");
|
f = sha1create("%s-%s.%s", base_name,
|
||||||
|
sha1_to_hex(object_list_sha1), "pack");
|
||||||
|
do_progress = progress;
|
||||||
|
}
|
||||||
|
if (do_progress)
|
||||||
|
fprintf(stderr, "Writing %d objects.\n", nr_objects);
|
||||||
|
|
||||||
hdr.hdr_signature = htonl(PACK_SIGNATURE);
|
hdr.hdr_signature = htonl(PACK_SIGNATURE);
|
||||||
hdr.hdr_version = htonl(PACK_VERSION);
|
hdr.hdr_version = htonl(PACK_VERSION);
|
||||||
hdr.hdr_entries = htonl(nr_objects);
|
hdr.hdr_entries = htonl(nr_objects);
|
||||||
|
@ -336,12 +344,18 @@ static void write_pack_file(void)
|
||||||
offset = sizeof(hdr);
|
offset = sizeof(hdr);
|
||||||
for (i = 0; i < nr_objects; i++) {
|
for (i = 0; i < nr_objects; i++) {
|
||||||
offset = write_one(f, objects + i, offset);
|
offset = write_one(f, objects + i, offset);
|
||||||
if (progress_update) {
|
if (do_progress) {
|
||||||
fprintf(stderr, "Writing (%d %d%%)\r",
|
unsigned percent = written * 100 / nr_objects;
|
||||||
i+1, (i+1) * 100/nr_objects);
|
if (progress_update || percent != last_percent) {
|
||||||
|
fprintf(stderr, "%4u%% (%u/%u) done\r",
|
||||||
|
percent, written, nr_objects);
|
||||||
progress_update = 0;
|
progress_update = 0;
|
||||||
|
last_percent = percent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (do_progress)
|
||||||
|
fputc('\n', stderr);
|
||||||
|
|
||||||
sha1close(f, pack_file_sha1, 1);
|
sha1close(f, pack_file_sha1, 1);
|
||||||
}
|
}
|
||||||
|
@ -680,10 +694,14 @@ static void find_deltas(struct object_entry **list, int window, int depth)
|
||||||
int i, idx;
|
int i, idx;
|
||||||
unsigned int array_size = window * sizeof(struct unpacked);
|
unsigned int array_size = window * sizeof(struct unpacked);
|
||||||
struct unpacked *array = xmalloc(array_size);
|
struct unpacked *array = xmalloc(array_size);
|
||||||
|
unsigned processed = 0;
|
||||||
|
unsigned last_percent = 999;
|
||||||
|
|
||||||
memset(array, 0, array_size);
|
memset(array, 0, array_size);
|
||||||
i = nr_objects;
|
i = nr_objects;
|
||||||
idx = 0;
|
idx = 0;
|
||||||
|
if (progress)
|
||||||
|
fprintf(stderr, "Deltifying %d objects.\n", nr_objects);
|
||||||
|
|
||||||
while (--i >= 0) {
|
while (--i >= 0) {
|
||||||
struct object_entry *entry = list[i];
|
struct object_entry *entry = list[i];
|
||||||
|
@ -692,10 +710,15 @@ static void find_deltas(struct object_entry **list, int window, int depth)
|
||||||
char type[10];
|
char type[10];
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
if (progress_update || i == 0) {
|
processed++;
|
||||||
fprintf(stderr, "Deltifying (%d %d%%)\r",
|
if (progress) {
|
||||||
nr_objects-i, (nr_objects-i) * 100/nr_objects);
|
unsigned percent = processed * 100 / nr_objects;
|
||||||
|
if (percent != last_percent || progress_update) {
|
||||||
|
fprintf(stderr, "%4u%% (%u/%u) done\r",
|
||||||
|
percent, processed, nr_objects);
|
||||||
progress_update = 0;
|
progress_update = 0;
|
||||||
|
last_percent = percent;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry->delta)
|
if (entry->delta)
|
||||||
|
|
Loading…
Reference in New Issue