Skip to content

Commit b40ba17

Browse files
committed
write-or-die: fix the polarity of GIT_FLUSH environment variable
When GIT_FLUSH is set to 1, true, on, yes, then we should disable skip_stdout_flush, but the conversion somehow did the opposite. With the understanding of the original motivation behind "skip" in 06f59e9 (Don't fflush(stdout) when it's not helpful, 2007-06-29), we can sympathize with the current naming (we wanted to avoid useless flushing of stdout by default, with an escape hatch to always flush), but it is still not a good excuse. Retire the "skip_stdout_flush" variable and replace it with "flush_stdout" that tells if we do or do not want to run fflush(). Reported-by: Xiaoguang WANG <[email protected]> Helped-by: Phillip Wood <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 556e680 commit b40ba17

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

write-or-die.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,20 @@
1818
*/
1919
void maybe_flush_or_die(FILE *f, const char *desc)
2020
{
21-
static int skip_stdout_flush = -1;
22-
2321
if (f == stdout) {
24-
if (skip_stdout_flush < 0) {
25-
skip_stdout_flush = git_env_bool("GIT_FLUSH", -1);
26-
if (skip_stdout_flush < 0) {
22+
static int force_flush_stdout = -1;
23+
24+
if (force_flush_stdout < 0) {
25+
force_flush_stdout = git_env_bool("GIT_FLUSH", -1);
26+
if (force_flush_stdout < 0) {
2727
struct stat st;
2828
if (fstat(fileno(stdout), &st))
29-
skip_stdout_flush = 0;
29+
force_flush_stdout = 1;
3030
else
31-
skip_stdout_flush = S_ISREG(st.st_mode);
31+
force_flush_stdout = !S_ISREG(st.st_mode);
3232
}
3333
}
34-
if (skip_stdout_flush && !ferror(f))
34+
if (!force_flush_stdout && !ferror(f))
3535
return;
3636
}
3737
if (fflush(f)) {

0 commit comments

Comments
 (0)