Skip to content

Commit 22d3a9a

Browse files
committed
pager: do not unnecessarily set COLUMNS on Windows
Since gwsw/less@bb0ee4e76c2, `less` prefers the `COLUMNS` variable over asking ncurses itself. This is typically not a problem because we ask `TIOCGWINSZ` in Git, to determine the correct value for `COLUMNS`. However, on Windows it _is_ a problem because Git for Windows' Bash (and `less.exe`) uses the MSYS2 runtime while `git.exe` does _not_, and therefore we never get the correct value in Git, but `less.exe` has no problem obtaining it. Let's not override `COLUMNS` in that case. This fixes #3235 Signed-off-by: Johannes Schindelin <[email protected]>
1 parent ebf3c04 commit 22d3a9a

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

pager.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,13 @@ void setup_pager(void)
111111
* to get the terminal size. Let's grab it now, and then set $COLUMNS
112112
* to communicate it to any sub-processes.
113113
*/
114+
#if !defined(WIN32) || defined(TIOCGWINSZ)
114115
{
115116
char buf[64];
116117
xsnprintf(buf, sizeof(buf), "%d", term_columns());
117118
setenv("COLUMNS", buf, 0);
118119
}
120+
#endif
119121

120122
setenv("GIT_PAGER_IN_USE", "true", 1);
121123

0 commit comments

Comments
 (0)