summaryrefslogtreecommitdiffstats
path: root/write-or-die.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-20 05:14:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-20 05:14:39 +0000
commit7260c37aa8c91c8008dcd2442a19c23d1c9040fb (patch)
tree83953428f11212a71a4616e535c1053076f9bb94 /write-or-die.c
parentReleasing progress-linux version 1:2.43.0-1~progress7.99u1. (diff)
downloadgit-7260c37aa8c91c8008dcd2442a19c23d1c9040fb.tar.xz
git-7260c37aa8c91c8008dcd2442a19c23d1c9040fb.zip
Merging upstream version 1:2.45.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'write-or-die.c')
-rw-r--r--write-or-die.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/write-or-die.c b/write-or-die.c
index 42a2dc7..01a9a51 100644
--- a/write-or-die.c
+++ b/write-or-die.c
@@ -18,23 +18,20 @@
*/
void maybe_flush_or_die(FILE *f, const char *desc)
{
- static int skip_stdout_flush = -1;
- struct stat st;
- char *cp;
-
if (f == stdout) {
- if (skip_stdout_flush < 0) {
- /* NEEDSWORK: make this a normal Boolean */
- cp = getenv("GIT_FLUSH");
- if (cp)
- skip_stdout_flush = (atoi(cp) == 0);
- else if ((fstat(fileno(stdout), &st) == 0) &&
- S_ISREG(st.st_mode))
- skip_stdout_flush = 1;
- else
- skip_stdout_flush = 0;
+ static int force_flush_stdout = -1;
+
+ if (force_flush_stdout < 0) {
+ force_flush_stdout = git_env_bool("GIT_FLUSH", -1);
+ if (force_flush_stdout < 0) {
+ struct stat st;
+ if (fstat(fileno(stdout), &st))
+ force_flush_stdout = 1;
+ else
+ force_flush_stdout = !S_ISREG(st.st_mode);
+ }
}
- if (skip_stdout_flush && !ferror(f))
+ if (!force_flush_stdout && !ferror(f))
return;
}
if (fflush(f)) {