diff options
Diffstat (limited to 'write-or-die.c')
| -rw-r--r-- | write-or-die.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/write-or-die.c b/write-or-die.c index aaa0318e82..3942152865 100644 --- a/write-or-die.c +++ b/write-or-die.c @@ -1,6 +1,7 @@ -#include "cache.h" -#include "config.h" +#include "git-compat-util.h" +#include "parse.h" #include "run-command.h" +#include "write-or-die.h" /* * Some cases use stdio, but want to flush after the write @@ -18,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; |
