All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pager: do not unnecessarily set COLUMNS on Windows
@ 2021-06-14 20:19 Johannes Schindelin via GitGitGadget
  2021-06-15  3:02 ` Junio C Hamano
  2021-06-16 12:38 ` [PATCH v2] " Johannes Schindelin via GitGitGadget
  0 siblings, 2 replies; 7+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2021-06-14 20:19 UTC (permalink / raw)
  To: git; +Cc: Johannes Schindelin, Johannes Schindelin

From: Johannes Schindelin <johannes.schindelin@gmx.de>

Since https://github.com/gwsw/less/commit/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 https://github.com/git-for-windows/git/issues/3235

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
    pager: do not unnecessarily set COLUMNS on Windows
    
    A recent upgrade of the "less" package in Git for Windows causes
    problems. Here is a work-around.

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-982%2Fdscho%2Ffix-duplicated-lines-when-moving-in-pager-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-982/dscho/fix-duplicated-lines-when-moving-in-pager-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/982

 pager.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/pager.c b/pager.c
index 3d37dd7adaa2..b84668eddca2 100644
--- a/pager.c
+++ b/pager.c
@@ -111,11 +111,13 @@ void setup_pager(void)
 	 * to get the terminal size. Let's grab it now, and then set $COLUMNS
 	 * to communicate it to any sub-processes.
 	 */
+#if !defined(WIN32) || defined(TIOCGWINSZ)
 	{
 		char buf[64];
 		xsnprintf(buf, sizeof(buf), "%d", term_columns());
 		setenv("COLUMNS", buf, 0);
 	}
+#endif
 
 	setenv("GIT_PAGER_IN_USE", "true", 1);
 

base-commit: ebf3c04b262aa27fbb97f8a0156c2347fecafafb
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-06-29  0:12 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-06-14 20:19 [PATCH] pager: do not unnecessarily set COLUMNS on Windows Johannes Schindelin via GitGitGadget
2021-06-15  3:02 ` Junio C Hamano
2021-06-16 12:38 ` [PATCH v2] " Johannes Schindelin via GitGitGadget
2021-06-17  2:20   ` Junio C Hamano
2021-06-17 11:43     ` Johannes Schindelin
2021-06-29  0:12       ` Junio C Hamano
2021-06-21 16:57   ` [PATCH v3] pager: avoid setting COLUMNS when we're guessing its value Johannes Schindelin via GitGitGadget

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.