diff options
author | Jiang Xin <worldhello.net@gmail.com> | 2021-08-03 17:03:35 +0800 |
---|---|---|
committer | Jiang Xin <worldhello.net@gmail.com> | 2021-08-03 17:03:35 +0800 |
commit | 972c9cf6aed660f3b4189a8f2adda505e67110ff (patch) | |
tree | 350bb2a29eb3360cdf36a30d8c8e7c76c3e61851 /pager.c | |
parent | l10n: fixed typos of mismatched constant strings (diff) | |
parent | Git 2.33-rc0 (diff) | |
download | tgif-972c9cf6aed660f3b4189a8f2adda505e67110ff.tar.xz |
Merge branch 'master' of github.com:git/git
* 'master' of github.com:git/git: (397 commits)
Git 2.33-rc0
The seventh batch
ci/install-dependencies: handle "sparse" job package installs
ci: run "apt-get update" before "apt-get install"
cache-tree: prefetch in partial clone read-tree
unpack-trees: refactor prefetching code
pack-bitmap: check pack validity when opening bitmap
bundle tests: use test_cmp instead of grep
bundle tests: use ">file" not ": >file"
The sixth batch
doc: pull: fix rebase=false documentation
pack-bitmap: clarify comment in filter_bitmap_exclude_type()
doc: clarify description of 'submodule.recurse'
doc/git-config: simplify "override" advice for FILES section
doc/git-config: clarify GIT_CONFIG environment variable
doc/git-config: explain --file instead of referring to GIT_CONFIG
t0000: fix test if run with TEST_OUTPUT_DIRECTORY
multi-pack-index: fix potential segfault without sub-command
refs/debug: quote prefix
t0000: clear GIT_SKIP_TESTS before running sub-tests
...
Diffstat (limited to 'pager.c')
-rw-r--r-- | pager.c | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -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 |