diff options
| author | Junio C Hamano <gitster@pobox.com> | 2024-02-08 16:22:04 -0800 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2024-02-08 16:22:04 -0800 |
| commit | 3c2ee131f88c2e65bfed514b7b164f542b046c0c (patch) | |
| tree | ad8f1aee6720e0a7c2d4e339fc2b4c65f0b6d27c /write-or-die.c | |
| parent | 8566311a03f8fbb185b6c8524d7eb4a74017bd4f (diff) | |
| parent | 556e68032f8248c831e48207e5cb923c9fe0e42c (diff) | |
| download | git-3c2ee131f88c2e65bfed514b7b164f542b046c0c.tar.xz | |
Merge branch 'cp/git-flush-is-an-env-bool' into maint-2.43
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
Diffstat (limited to 'write-or-die.c')
| -rw-r--r-- | write-or-die.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/write-or-die.c b/write-or-die.c index 42a2dc73cd..3942152865 100644 --- a/write-or-die.c +++ b/write-or-die.c @@ -19,20 +19,17 @@ 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; |
