summaryrefslogtreecommitdiff
path: root/pager.c
diff options
context:
space:
mode:
Diffstat (limited to 'pager.c')
-rw-r--r--pager.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/pager.c b/pager.c
index 3d37dd7ada..52f27a6765 100644
--- a/pager.c
+++ b/pager.c
@@ -11,6 +11,10 @@
static struct child_process pager_process = CHILD_PROCESS_INIT;
static const char *pager_program;
+/* Is the value coming back from term_columns() just a guess? */
+static int term_columns_guessed;
+
+
static void close_pager_fds(void)
{
/* signal EOF to pager */
@@ -114,7 +118,8 @@ void setup_pager(void)
{
char buf[64];
xsnprintf(buf, sizeof(buf), "%d", term_columns());
- setenv("COLUMNS", buf, 0);
+ if (!term_columns_guessed)
+ setenv("COLUMNS", buf, 0);
}
setenv("GIT_PAGER_IN_USE", "true", 1);
@@ -158,15 +163,20 @@ int term_columns(void)
return term_columns_at_startup;
term_columns_at_startup = 80;
+ term_columns_guessed = 1;
col_string = getenv("COLUMNS");
- if (col_string && (n_cols = atoi(col_string)) > 0)
+ if (col_string && (n_cols = atoi(col_string)) > 0) {
term_columns_at_startup = n_cols;
+ term_columns_guessed = 0;
+ }
#ifdef TIOCGWINSZ
else {
struct winsize ws;
- if (!ioctl(1, TIOCGWINSZ, &ws) && ws.ws_col)
+ if (!ioctl(1, TIOCGWINSZ, &ws) && ws.ws_col) {
term_columns_at_startup = ws.ws_col;
+ term_columns_guessed = 0;
+ }
}
#endif