allow command-specific pagers in pager.<cmd>
[gitweb.git] / t / t7006-pager.sh
index 017565f3329795b9c8cd39b76fa03e2a16bb3067..49a62616936e176cb89c20497c6b0c15b969e0a6 100755 (executable)
@@ -134,7 +134,7 @@ test_expect_success TTY 'configuration can disable pager' '
        ! test -e paginated.out
 '
 
-test_expect_success 'git config uses a pager if configured to' '
+test_expect_success TTY 'git config uses a pager if configured to' '
        rm -f paginated.out &&
        git config pager.config true &&
        test_when_finished "git config --unset pager.config" &&
@@ -142,7 +142,7 @@ test_expect_success 'git config uses a pager if configured to' '
        test -e paginated.out
 '
 
-test_expect_success 'configuration can enable pager (from subdir)' '
+test_expect_success TTY 'configuration can enable pager (from subdir)' '
        rm -f paginated.out &&
        mkdir -p subdir &&
        git config pager.bundle true &&
@@ -435,4 +435,33 @@ test_core_pager_subdir    expect_success 'git -p shortlog'
 test_core_pager_subdir    expect_success test_must_fail \
                                         'git -p apply </dev/null'
 
+test_expect_success TTY 'command-specific pager' '
+       unset PAGER GIT_PAGER;
+       echo "foo:initial" >expect &&
+       >actual &&
+       git config --unset core.pager &&
+       git config pager.log "sed s/^/foo:/ >actual" &&
+       test_terminal git log --format=%s -1 &&
+       test_cmp expect actual
+'
+
+test_expect_success TTY 'command-specific pager overrides core.pager' '
+       unset PAGER GIT_PAGER;
+       echo "foo:initial" >expect &&
+       >actual &&
+       git config core.pager "exit 1"
+       git config pager.log "sed s/^/foo:/ >actual" &&
+       test_terminal git log --format=%s -1 &&
+       test_cmp expect actual
+'
+
+test_expect_success TTY 'command-specific pager overridden by environment' '
+       GIT_PAGER="sed s/^/foo:/ >actual" && export GIT_PAGER &&
+       >actual &&
+       echo "foo:initial" >expect &&
+       git config pager.log "exit 1" &&
+       test_terminal git log --format=%s -1 &&
+       test_cmp expect actual
+'
+
 test_done