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(-)
Show changes to progress.c +4 −2
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