Merge branch 'kd/auto-col-with-pager-fix'
authorJunio C Hamano <gitster@pobox.com>
Mon, 6 Nov 2017 04:11:22 +0000 (13:11 +0900)
committerJunio C Hamano <gitster@pobox.com>
Mon, 6 Nov 2017 04:11:22 +0000 (13:11 +0900)
"auto" as a value for the columnar output configuration ought to
judge "is the output consumed by humans?" with the same criteria as
"auto" for coloured output configuration, i.e. either the standard
output stream is going to tty, or a pager is in use. We forgot the
latter, which has been fixed.

* kd/auto-col-with-pager-fix:
column: do not include pager.c
column: show auto columns when pager is active

column.c
t/t7006-pager.sh
index ff7bdab1a32478c8719ee3b973742456df7dc629..49ab85b76916784d5d5e6d6ef15a9638ef97b59f 100644 (file)
--- a/column.c
+++ b/column.c
@@ -224,7 +224,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;
index f0f1abd1c23d4303a686310d7325cd523d6c921b..865168ec6a7be7fc7778419f2dd1066e9c80c1bc 100755 (executable)
@@ -570,4 +570,18 @@ test_expect_success 'command with underscores does not complain' '
        test_cmp expect actual
 '
 
+test_expect_success TTY 'git tag with auto-columns ' '
+       test_commit one &&
+       test_commit two &&
+       test_commit three &&
+       test_commit four &&
+       test_commit five &&
+       cat >expect <<-\EOF &&
+       initial  one      two      three    four     five
+       EOF
+       test_terminal env PAGER="cat >actual" COLUMNS=80 \
+               git -c column.ui=auto tag --sort=authordate &&
+       test_cmp expect actual
+'
+
 test_done