git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Alex Riesen" <raa.lkml@gmail.com>
To: "Git Mailing List" <git@vger.kernel.org>
Cc: "Junio C Hamano" <junkio@cox.net>
Subject: [PATCH] Fix the progress code to output LF only when it is really needed
Date: Wed, 23 May 2007 18:07:25 +0200	[thread overview]
Message-ID: <81b0412b0705230907x482a0f52n6e6b2302f0f20d04@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 275 bytes --]

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
---

I was wondering about why git-reset --hard now prints an empty
line between the command and the oneline commit description.

 progress.c |    6 +++++-
 progress.h |    1 +
 2 files changed, 6 insertions(+), 1 deletions(-)

[-- Attachment #2: 0001-Fix-the-progress-code-to-output-LF-only-when-it-is-rea.txt --]
[-- Type: text/plain, Size: 1933 bytes --]

From 139c597fecbb9ddf18c47b12cc97c42763a133bf Mon Sep 17 00:00:00 2001
From: Alex Riesen <raa.lkml@gmail.com>
Date: Wed, 23 May 2007 17:55:28 +0200
Subject: [PATCH] Fix the progress code to output LF only when it is really needed


Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
---
 progress.c |    6 +++++-
 progress.h |    1 +
 2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/progress.c b/progress.c
index 05f7890..4344f4e 100644
--- a/progress.c
+++ b/progress.c
@@ -62,11 +62,13 @@ int display_progress(struct progress *progress, unsigned n)
 			fprintf(stderr, "%s%4u%% (%u/%u) done\r",
 				progress->prefix, percent, n, progress->total);
 			progress_update = 0;
+			progress->need_lf = 1;
 			return 1;
 		}
 	} else if (progress_update) {
 		fprintf(stderr, "%s%u\r", progress->prefix, n);
 		progress_update = 0;
+		progress->need_lf = 1;
 		return 1;
 	}
 	return 0;
@@ -80,6 +82,7 @@ void start_progress(struct progress *progress, const char *title,
 	progress->total = total;
 	progress->last_percent = -1;
 	progress->delay = 0;
+	progress->need_lf = 0;
 	if (snprintf(buf, sizeof(buf), title, total))
 		fprintf(stderr, "%s\n", buf);
 	set_progress_signal();
@@ -95,12 +98,13 @@ void start_progress_delay(struct progress *progress, const char *title,
 	progress->delayed_percent_treshold = percent_treshold;
 	progress->delayed_title = title;
 	progress->delay = delay;
+	progress->need_lf = 0;
 	set_progress_signal();
 }
 
 void stop_progress(struct progress *progress)
 {
 	clear_progress_signal();
-	if (progress->total)
+	if (progress->need_lf)
 		fputc('\n', stderr);
 }
diff --git a/progress.h b/progress.h
index 5ae1a89..a7c17ca 100644
--- a/progress.h
+++ b/progress.h
@@ -8,6 +8,7 @@ struct progress {
 	unsigned delay;
 	unsigned delayed_percent_treshold;
 	const char *delayed_title;
+	int need_lf;
 };
 
 int display_progress(struct progress *progress, unsigned n);
-- 
1.5.2.787.g56770


                 reply	other threads:[~2007-05-23 16:07 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=81b0412b0705230907x482a0f52n6e6b2302f0f20d04@mail.gmail.com \
    --to=raa.lkml@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).