From: Jeff King Date: Tue, 19 May 2015 05:24:57 +0000 (-0400) Subject: progress: treat "no terminal" as being in the foreground X-Git-Tag: v2.5.0-rc0~82^2 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/a4fb76ce1916939c7e6359f9416f2af4a760f6f1?hp=--cc progress: treat "no terminal" as being in the foreground progress: treat "no terminal" as being in the foreground Commit 85cb890 (progress: no progress in background, 2015-04-13) avoids sending progress from background processes by checking that the process group id of the current process is the same as that of the controlling terminal. If we don't have a terminal, however, this check never succeeds, and we print no progress at all (until the final "done" message). This can be seen when cloning a large repository; instead of getting progress updates for "counting objects", it will appear to hang then print the final count. We can fix this by treating an error return from tcgetpgrp() as a signal to show the progress. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- a4fb76ce1916939c7e6359f9416f2af4a760f6f1 diff --git a/progress.c b/progress.c index 43d9228378..2e31bec60f 100644 --- a/progress.c +++ b/progress.c @@ -74,7 +74,8 @@ static void clear_progress_signal(void) static int is_foreground_fd(int fd) { - return getpgid(0) == tcgetpgrp(fd); + int tpgrp = tcgetpgrp(fd); + return tpgrp < 0 || tpgrp == getpgid(0); } static int display(struct progress *progress, unsigned n, const char *done)