]> git.ipfire.org Git - thirdparty/git.git/blobdiff - write-or-die.c
Start the 2.46 cycle
[thirdparty/git.git] / write-or-die.c
index 39421528653e29cbd724153edf94d2613ea1d6b4..01a9a51fa2fcd758b32ffc8f3e75811710804754 100644 (file)
  */
 void maybe_flush_or_die(FILE *f, const char *desc)
 {
-       static int skip_stdout_flush = -1;
-
        if (f == stdout) {
-               if (skip_stdout_flush < 0) {
-                       skip_stdout_flush = git_env_bool("GIT_FLUSH", -1);
-                       if (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))
-                                       skip_stdout_flush = 0;
+                                       force_flush_stdout = 1;
                                else
-                                       skip_stdout_flush = S_ISREG(st.st_mode);
+                                       force_flush_stdout = !S_ISREG(st.st_mode);
                        }
                }
-               if (skip_stdout_flush && !ferror(f))
+               if (!force_flush_stdout && !ferror(f))
                        return;
        }
        if (fflush(f)) {