Code

Merge branch 'jn/update-contrib-example-merge'
[git.git] / t / t7006-pager.sh
index 43b310218ae7a4b17e66f3b5949cf42218da07c8..fb744e3c4a9a19d9285fc04053044242ffed0c65 100755 (executable)
@@ -58,6 +58,21 @@ test_expect_success TTY 'some commands use a pager' '
        test -e paginated.out
 '
 
+test_expect_failure TTY 'pager runs from subdir' '
+       echo subdir/paginated.out >expected &&
+       mkdir -p subdir &&
+       rm -f paginated.out subdir/paginated.out &&
+       (
+               cd subdir &&
+               test_terminal git log
+       ) &&
+       {
+               ls paginated.out subdir/paginated.out ||
+               :
+       } >actual &&
+       test_cmp expected actual
+'
+
 test_expect_success TTY 'some commands do not use a pager' '
        rm -f paginated.out ||
        cleanup_fail &&
@@ -106,6 +121,45 @@ test_expect_success TTY 'no pager with --no-pager' '
        ! test -e paginated.out
 '
 
+test_expect_success TTY 'configuration can disable pager' '
+       rm -f paginated.out &&
+       test_might_fail git config --unset pager.grep &&
+       test_terminal git grep initial &&
+       test -e paginated.out &&
+
+       rm -f paginated.out &&
+       git config pager.grep false &&
+       test_when_finished "git config --unset pager.grep" &&
+       test_terminal git grep initial &&
+       ! test -e paginated.out
+'
+
+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" &&
+       test_terminal git config --list &&
+       test -e paginated.out
+'
+
+test_expect_success TTY 'configuration can enable pager (from subdir)' '
+       rm -f paginated.out &&
+       mkdir -p subdir &&
+       git config pager.bundle true &&
+       test_when_finished "git config --unset pager.bundle" &&
+
+       git bundle create test.bundle --all &&
+       rm -f paginated.out subdir/paginated.out &&
+       (
+               cd subdir &&
+               test_terminal git bundle unbundle ../test.bundle
+       ) &&
+       {
+               test -e paginated.out ||
+               test -e subdir/paginated.out
+       }
+'
+
 # A colored commit log will begin with an appropriate ANSI escape
 # for the first color; the text "commit" comes later.
 colorful() {
@@ -378,4 +432,7 @@ test_no_local_config_subdir expect_success 'git shortlog'
 test_default_pager        expect_success 'git -p shortlog'
 test_core_pager_subdir    expect_success 'git -p shortlog'
 
+test_core_pager_subdir    expect_success test_must_fail \
+                                        'git -p apply </dev/null'
+
 test_done