In reality, checking sources, git output is not buffered by less all the time.
Checking pager.c, it shows git output is buffered by the program pointed to the PAGER shell variable; if it is not defined, less will be used by omission.
More interestingly yet, while the less output is being paged, it sets the shell GIT_PAGER_IN_USE variable to true. When invoking the pager, it checks for that variable.
As an oddity, it seems it does not like cat as a pager, if it detects it, it blanks it out.
#ifndef DEFAULT_PAGER
#define DEFAULT_PAGER "less"
#endif
....
void setup_pager(void)
{
const char *pager = git_pager(isatty(1));
if (!pager)
return;
/*
* After we redirect standard output, we won't be able to use an ioctl
* to get the terminal size. Let's grab it now, and then set $COLUMNS
* to communicate it to any sub-processes.
*/
{
char buf[64];
xsnprintf(buf, sizeof(buf), "%d", term_columns());
setenv("COLUMNS", buf, 0);
}
setenv("GIT_PAGER_IN_USE", "true", 1);
/* spawn the pager */
prepare_pager_args(&pager_process, pager);
pager_process.in = -1;
argv_array_push(&pager_process.env_array, "GIT_PAGER_IN_USE");
if (start_command(&pager_process))
return;
/* original process continues, but writes to the pipe */
dup2(pager_process.in, 1);
if (isatty(2))
dup2(pager_process.in, 2);
close(pager_process.in);
/* this makes sure that the parent terminates after the pager */
sigchain_push_common(wait_for_pager_signal);
atexit(wait_for_pager_atexit);
}
less).