]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'cp/git-flush-is-an-env-bool' into maint-2.43
authorJunio C Hamano <gitster@pobox.com>
Fri, 9 Feb 2024 00:22:04 +0000 (16:22 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 9 Feb 2024 00:22:04 +0000 (16:22 -0800)
Unlike other environment variables that took the usual
true/false/yes/no as well as 0/1, GIT_FLUSH only understood 0/1,
which has been corrected.

* cp/git-flush-is-an-env-bool:
  write-or-die: make GIT_FLUSH a Boolean environment variable

Documentation/git.txt
write-or-die.c

index 4698d7a42b5d4cd23a30b953313928fc73bcb76c..caa6cbee7ebef3a2b9ee515e7a89bdfbc26c11ec 100644 (file)
@@ -724,13 +724,12 @@ for further details.
        waiting for someone with sufficient permissions to fix it.
 
 `GIT_FLUSH`::
-// NEEDSWORK: make it into a usual Boolean environment variable
-       If this environment variable is set to "1", then commands such
+       If this Boolean environment variable is set to true, then commands such
        as 'git blame' (in incremental mode), 'git rev-list', 'git log',
        'git check-attr' and 'git check-ignore' will
        force a flush of the output stream after each record have been
        flushed. If this
-       variable is set to "0", the output of these commands will be done
+       variable is set to false, the output of these commands will be done
        using completely buffered I/O.   If this environment variable is
        not set, Git will choose buffered or record-oriented flushing
        based on whether stdout appears to be redirected to a file or not.
index 42a2dc73cd3f18638445780e7fa9aa9b67ba871c..39421528653e29cbd724153edf94d2613ea1d6b4 100644 (file)
 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;
+                       skip_stdout_flush = git_env_bool("GIT_FLUSH", -1);
+                       if (skip_stdout_flush < 0) {
+                               struct stat st;
+                               if (fstat(fileno(stdout), &st))
+                                       skip_stdout_flush = 0;
+                               else
+                                       skip_stdout_flush = S_ISREG(st.st_mode);
+                       }
                }
                if (skip_stdout_flush && !ferror(f))
                        return;