mirror of
https://github.com/git/git
synced 2024-08-24 18:26:02 +00:00
pager: Work around window resizing bug in 'less'
If you resize the terminal while less is waiting for input, less will exit entirely without even showing the output. This is very noticeable if you do something like "git diff" on a big and cold-cache tree and git takes a few seconds to think, and then you resize the window while it's preparing. Boom. No output AT ALL. The way to reproduce the problem is to do some pager operation that takes a while in git, and resizing the window while git is thinking about the output. Try git diff --stat v2.6.12.. in the kernel tree to do something where it takes a while for git to start outputting information. Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
parent
b6f5da1e0f
commit
35ce862279
12
pager.c
12
pager.c
|
@ -1,5 +1,7 @@
|
||||||
#include "cache.h"
|
#include "cache.h"
|
||||||
|
|
||||||
|
#include <sys/select.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is split up from the rest of git so that we might do
|
* This is split up from the rest of git so that we might do
|
||||||
* something different on Windows, for example.
|
* something different on Windows, for example.
|
||||||
|
@ -7,6 +9,16 @@
|
||||||
|
|
||||||
static void run_pager(const char *pager)
|
static void run_pager(const char *pager)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* Work around bug in "less" by not starting it until we
|
||||||
|
* have real input
|
||||||
|
*/
|
||||||
|
fd_set in;
|
||||||
|
|
||||||
|
FD_ZERO(&in);
|
||||||
|
FD_SET(0, &in);
|
||||||
|
select(1, &in, NULL, &in, NULL);
|
||||||
|
|
||||||
execlp(pager, pager, NULL);
|
execlp(pager, pager, NULL);
|
||||||
execl("/bin/sh", "sh", "-c", pager, NULL);
|
execl("/bin/sh", "sh", "-c", pager, NULL);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue