Subject: Re: [PATCH] Change 'Deltifying objects' to 'Delta compressing objects'

From: "Shawn O. Pearce" <[email-masked]>
Date: Thu, 18 Oct 2007 23:17:37 -0400

Nicolas Pitre <[email-masked]> wrote:
> On Thu, 18 Oct 2007, Shawn O. Pearce wrote:
> 
> > I really don't have an opinion either way.  Actually I think the
> > entire progress system of git-pack-objects should be reduced even
> > further so that users aren't exposed to the internal phases we
> > are going through.  Most of them just don't care.  They just
> > want to know when its going to be done[*1*].
> 
> Well, with my latest patches in that area, the typical progress on 
> screen has been cut in half.  And the different phases are intertaining.

Yup.  Your patches were a big improvement.  But I'm now sitting here
wondering if we shouldn't just allow a progress meter to overwrite
the prior one.  Then you only see the current task and progress,
or the final output if we have nothing further to say about that.

Hmmph.  Maybe something like this:

I like how it comes out in the end, but it really screws with the
sideband protocol.  Like horribly.  I got a whole ton of "remote:
remote: remote: remote: remote: remote:" during a remote clone.

diff --git a/progress.c b/progress.c
index 7629e05..099fc14 100644
--- a/progress.c
+++ b/progress.c
@@ -37,8 +37,6 @@ static void clear_progress_signal(void)
 
 static int display(struct progress *progress, unsigned n, int done)
 {
-	char *eol;
-
 	if (progress->delay) {
 		if (!progress_update || --progress->delay)
 			return 0;
@@ -55,18 +53,26 @@ static int display(struct progress *progress, unsigned n, int done)
 	}
 
 	progress->last_value = n;
-	eol = done ? ", done.   \n" : "   \r";
-	if (progress->total) {
+	if (done) {
+		size_t c = strlen(progress->title);
+		while (c--)
+			fputc(' ', stderr);
+		fputs("            ", stderr);
+		for (; n > 0; n /= 10)
+			fputs("  ", stderr);
+		fputc('\r', stderr);
+		return 1;
+	} else if (progress->total) {
 		unsigned percent = n * 100 / progress->total;
 		if (percent != progress->last_percent || progress_update) {
 			progress->last_percent = percent;
 			fprintf(stderr, "%s: %3u%% (%u/%u)%s", progress->title,
-				percent, n, progress->total, eol);
+				percent, n, progress->total, "   \r");
 			progress_update = 0;
 			return 1;
 		}
 	} else if (progress_update) {
-		fprintf(stderr, "%s: %u%s", progress->title, n, eol);
+		fprintf(stderr, "%s: %u%s", progress->title, n, "   \r");
 		progress_update = 0;
 		return 1;
 	}

-- 
Shawn.