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 variablemaint
commit
3c2ee131f8
|
|
@ -724,13 +724,12 @@ for further details.
|
||||||
waiting for someone with sufficient permissions to fix it.
|
waiting for someone with sufficient permissions to fix it.
|
||||||
|
|
||||||
`GIT_FLUSH`::
|
`GIT_FLUSH`::
|
||||||
// NEEDSWORK: make it into a usual Boolean environment variable
|
If this Boolean environment variable is set to true, then commands such
|
||||||
If this environment variable is set to "1", then commands such
|
|
||||||
as 'git blame' (in incremental mode), 'git rev-list', 'git log',
|
as 'git blame' (in incremental mode), 'git rev-list', 'git log',
|
||||||
'git check-attr' and 'git check-ignore' will
|
'git check-attr' and 'git check-ignore' will
|
||||||
force a flush of the output stream after each record have been
|
force a flush of the output stream after each record have been
|
||||||
flushed. If this
|
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
|
using completely buffered I/O. If this environment variable is
|
||||||
not set, Git will choose buffered or record-oriented flushing
|
not set, Git will choose buffered or record-oriented flushing
|
||||||
based on whether stdout appears to be redirected to a file or not.
|
based on whether stdout appears to be redirected to a file or not.
|
||||||
|
|
|
||||||
|
|
@ -19,20 +19,17 @@
|
||||||
void maybe_flush_or_die(FILE *f, const char *desc)
|
void maybe_flush_or_die(FILE *f, const char *desc)
|
||||||
{
|
{
|
||||||
static int skip_stdout_flush = -1;
|
static int skip_stdout_flush = -1;
|
||||||
struct stat st;
|
|
||||||
char *cp;
|
|
||||||
|
|
||||||
if (f == stdout) {
|
if (f == stdout) {
|
||||||
if (skip_stdout_flush < 0) {
|
if (skip_stdout_flush < 0) {
|
||||||
/* NEEDSWORK: make this a normal Boolean */
|
skip_stdout_flush = git_env_bool("GIT_FLUSH", -1);
|
||||||
cp = getenv("GIT_FLUSH");
|
if (skip_stdout_flush < 0) {
|
||||||
if (cp)
|
struct stat st;
|
||||||
skip_stdout_flush = (atoi(cp) == 0);
|
if (fstat(fileno(stdout), &st))
|
||||||
else if ((fstat(fileno(stdout), &st) == 0) &&
|
skip_stdout_flush = 0;
|
||||||
S_ISREG(st.st_mode))
|
else
|
||||||
skip_stdout_flush = 1;
|
skip_stdout_flush = S_ISREG(st.st_mode);
|
||||||
else
|
}
|
||||||
skip_stdout_flush = 0;
|
|
||||||
}
|
}
|
||||||
if (skip_stdout_flush && !ferror(f))
|
if (skip_stdout_flush && !ferror(f))
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue