Re: [PATCH] nicer eye candies for pack-objects
- From
Junio C Hamano <junkio@cox.net>
- Date
- Feb 22, 2006, 22:27 UTC
- Message-ID
- <7vy803kp1n.fsf@assigned-by-dhcp.cox.net>
- In-Reply-To
- <Pine.LNX.4.64.0602221549250.5606@localhost.localdomain>
I like this, but like the "every second or every percent whichever comes first" unpack-objects does even better. How about something like this on top of your patch?
---
diff --git a/pack-objects.c b/pack-objects.c index 5e1e14c..d05ab23 100644 --- a/pack-objects.c +++ b/pack-objects.c @@ -674,10 +674,14 @@ static void find_deltas(struct object_en int i, idx; unsigned int array_size = window * sizeof(struct unpacked); struct unpacked *array = xmalloc(array_size); + unsigned processed = 0; + unsigned last_percent = 999; memset(array, 0, array_size); i = nr_objects; idx = 0; + if (progress) + fprintf(stderr, "Deltifying %d objects.\n", nr_objects); while (--i >= 0) { struct object_entry *entry = list[i]; @@ -686,10 +690,15 @@ static void find_deltas(struct object_en char type[10]; int j; - if (progress_update || i == 0) { - fprintf(stderr, "Deltifying (%d %d%%)\r", - nr_objects-i, (nr_objects-i) * 100/nr_objects); - progress_update = 0; + processed++; + if (progress) { + 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; + last_percent = percent; + } } if (entry->delta)