git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [RFC] column: show auto columns when pager is active
@ 2017-10-09 21:45 Kevin Daudt
  2017-10-09 23:27 ` Eric Sunshine
                   ` (3 more replies)
  0 siblings, 4 replies; 21+ messages in thread
From: Kevin Daudt @ 2017-10-09 21:45 UTC (permalink / raw)
  To: git; +Cc: pclouds, Kevin Daudt

When columns are set to automatic for git tag and the output is
paginated by git, the output is a single column instead of multiple
columns.

Standard behaviour in git is to honor auto values when the pager is
active, which happens for example with commands like git log showing
colors when being paged.

Since ff1e72483 (tag: change default of `pager.tag` to "on",
2017-08-02), the pager has been enabled by default, exposing this
problem to more people.

finalize_colopts in column.c only checks whether the output is a TTY to
determine if columns should be enabled with columns set to autol. Also check
if the pager is active.

Helped-by: Rafael Ascensão <rafa.almas@gmail.com>
Signed-off-by: Kevin Daudt <me@ikke.info>
---
This came to light when someone wondered on irc why
column.tag=[auto|always] did not work on Mac OS. Testing it myself, I
found it to work with always, but not with auto.

I could not get the test to work yet, because somehow it's not giving
any output, so feedback regarding that is welcome.


 column.c          |  3 ++-
 t/t9002-column.sh | 13 +++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/column.c b/column.c
index ff7bdab1a..ded50337f 100644
--- a/column.c
+++ b/column.c
@@ -5,6 +5,7 @@
 #include "parse-options.h"
 #include "run-command.h"
 #include "utf8.h"
+#include "pager.c"
 
 #define XY2LINEAR(d, x, y) (COL_LAYOUT((d)->colopts) == COL_COLUMN ? \
 			    (x) * (d)->rows + (y) : \
@@ -224,7 +225,7 @@ int finalize_colopts(unsigned int *colopts, int stdout_is_tty)
 		if (stdout_is_tty < 0)
 			stdout_is_tty = isatty(1);
 		*colopts &= ~COL_ENABLE_MASK;
-		if (stdout_is_tty)
+		if (stdout_is_tty || pager_in_use())
 			*colopts |= COL_ENABLED;
 	}
 	return 0;
diff --git a/t/t9002-column.sh b/t/t9002-column.sh
index 89983527b..9441145bf 100755
--- a/t/t9002-column.sh
+++ b/t/t9002-column.sh
@@ -2,6 +2,7 @@
 
 test_description='git column'
 . ./test-lib.sh
+. "$TEST_DIRECTORY"/lib-terminal.sh
 
 test_expect_success 'setup' '
 	cat >lista <<\EOF
@@ -177,4 +178,16 @@ EOF
 	test_cmp expected actual
 '
 
+test_expect_success TTY '20 columns, mode auto, pager' '
+	cat >expected <<\EOF &&
+one    seven
+two    eight
+three  nine
+four   ten
+five   eleven
+six
+EOF
+	test_terminal env PAGER="cat|cat" git column --mode=auto <lista >actual &&
+	test_cmp expected actual
+'
 test_done
-- 
2.14.2


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

end of thread, other threads:[~2017-10-24  6:58 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-09 21:45 [RFC] column: show auto columns when pager is active Kevin Daudt
2017-10-09 23:27 ` Eric Sunshine
2017-10-10 10:30 ` Martin Ågren
2017-10-10 14:01   ` Jeff King
2017-10-10 17:02     ` Martin Ågren
2017-10-11  4:54       ` Kevin Daudt
2017-10-12 14:24         ` Jeff King
2017-10-10 14:10 ` Jeff King
2017-10-10 14:29   ` Jeff King
2017-10-10 17:04     ` Martin Ågren
2017-10-10 18:32       ` Kevin Daudt
2017-10-11 17:23 ` [PATCH] " Kevin Daudt
2017-10-11 18:12   ` Martin Ågren
2017-10-11 18:36     ` Kevin Daudt
2017-10-11 19:02       ` Martin Ågren
2017-10-16 18:35   ` [PATCH v2] " Kevin Daudt
2017-10-17  3:19     ` Junio C Hamano
2017-10-23 21:52     ` Jonathan Nieder
2017-10-24  1:11       ` Junio C Hamano
2017-10-24  1:18         ` Jonathan Nieder
2017-10-24  6:58       ` Kevin Daudt

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).