git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] progress: don't print if !isatty(2).
@ 2012-05-24  5:18 Avery Pennarun
  2012-05-24  5:45 ` Jeff King
  0 siblings, 1 reply; 11+ messages in thread
From: Avery Pennarun @ 2012-05-24  5:18 UTC (permalink / raw)
  To: git, gitster; +Cc: Avery Pennarun

If stderr isn't a tty, we shouldn't be printing incremental progress
messages.  In particular, this affected 'git checkout -f . >&logfile' unless
you provided -q.  And git-new-workdir has no way to provide -q.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
---
 progress.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/progress.c b/progress.c
index 3971f49..4d9f416 100644
--- a/progress.c
+++ b/progress.c
@@ -211,9 +211,11 @@ int display_progress(struct progress *progress, unsigned n)
 struct progress *start_progress_delay(const char *title, unsigned total,
 				       unsigned percent_treshold, unsigned delay)
 {
-	struct progress *progress = malloc(sizeof(*progress));
+	struct progress *progress = NULL;
+	if (isatty(2))
+		progress = malloc(sizeof(*progress));
 	if (!progress) {
-		/* unlikely, but here's a good fallback */
+		/* use a simple fallback */
 		fprintf(stderr, "%s...\n", title);
 		fflush(stderr);
 		return NULL;
-- 
1.7.9.dirty

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2012-05-24 21:46 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-24  5:18 [PATCH] progress: don't print if !isatty(2) Avery Pennarun
2012-05-24  5:45 ` Jeff King
2012-05-24  6:05   ` [PATCH] checkout: default to quiet " Avery Pennarun
2012-05-24  6:10     ` Jeff King
2012-05-24  6:12       ` [PATCH v2] checkout: no progress messages " Avery Pennarun
2012-05-24 18:29         ` Junio C Hamano
2012-05-24 18:34           ` Jeff King
2012-05-24 18:49             ` Avery Pennarun
2012-05-24 18:46           ` Avery Pennarun
2012-05-24 21:46             ` Junio C Hamano
2012-05-24  6:12       ` [PATCH] checkout: default to quiet " Avery Pennarun

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).