#!/bin/sh global test_description := ''Test automatic use of a pager.'' source ./test-lib.sh source "$TEST_DIRECTORY"/lib-pager.sh source "$TEST_DIRECTORY"/lib-terminal.sh test_expect_success 'setup' ' sane_unset GIT_PAGER GIT_PAGER_IN_USE && test_unconfig core.pager && PAGER="cat >paginated.out" && export PAGER && test_commit initial ' test_expect_success TTY 'some commands use a pager' ' rm -f paginated.out && test_terminal git log && 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 'LESS and LV envvars are set for pagination' ' ( sane_unset LESS LV && PAGER="env >pager-env.out; wc" && export PAGER && test_terminal git log ) && grep ^LESS= pager-env.out && grep ^LV= pager-env.out ' test_expect_success !MINGW,TTY 'LESS and LV envvars set by git-sh-setup' ' ( sane_unset LESS LV && PAGER="env >pager-env.out; wc" && export PAGER && PATH="$(git --exec-path):$PATH" && export PATH && test_terminal sh -c ". git-sh-setup && git_pager" ) && grep ^LESS= pager-env.out && grep ^LV= pager-env.out ' test_expect_success TTY 'some commands do not use a pager' ' rm -f paginated.out && test_terminal git rev-list HEAD && ! test -e paginated.out ' test_expect_success 'no pager when stdout is a pipe' ' rm -f paginated.out && git log | cat && ! test -e paginated.out ' test_expect_success 'no pager when stdout is a regular file' ' rm -f paginated.out && git log >file && ! test -e paginated.out ' test_expect_success TTY 'git --paginate rev-list uses a pager' ' rm -f paginated.out && test_terminal git --paginate rev-list HEAD && test -e paginated.out ' test_expect_success 'no pager even with --paginate when stdout is a pipe' ' rm -f file paginated.out && git --paginate log | cat && ! test -e paginated.out ' test_expect_success TTY 'no pager with --no-pager' ' rm -f paginated.out && test_terminal git --no-pager log && ! test -e paginated.out ' test_expect_success TTY 'configuration can disable pager' ' rm -f paginated.out && test_unconfig pager.grep && test_terminal git grep initial && test -e paginated.out && rm -f paginated.out && test_config pager.grep false && 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 && test_config pager.config true && 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 && test_config pager.bundle true && 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. proc colorful { read firstline <$1 ! expr $firstline : "[a-zA-Z]" >/dev/null } test_expect_success 'tests can detect color' ' rm -f colorful.log colorless.log && git log --no-color >colorless.log && git log --color >colorful.log && ! colorful colorless.log && colorful colorful.log ' test_expect_success 'no color when stdout is a regular file' ' rm -f colorless.log && test_config color.ui auto && git log >colorless.log && ! colorful colorless.log ' test_expect_success TTY 'color when writing to a pager' ' rm -f paginated.out && test_config color.ui auto && test_terminal env TERM=vt100 git log && colorful paginated.out ' test_expect_success TTY 'colors are suppressed by color.pager' ' rm -f paginated.out && test_config color.ui auto && test_config color.pager false && test_terminal env TERM=vt100 git log && ! colorful paginated.out ' test_expect_success 'color when writing to a file intended for a pager' ' rm -f colorful.log && test_config color.ui auto && ( TERM=vt100 && GIT_PAGER_IN_USE=true && export TERM GIT_PAGER_IN_USE && git log >colorful.log ) && colorful colorful.log ' test_expect_success TTY 'colors are sent to pager for external commands' ' test_config alias.externallog "!git log" && test_config color.ui auto && test_terminal env TERM=vt100 git -p externallog && colorful paginated.out ' # Use this helper to make it easy for the caller of your # terminal-using function to specify whether it should fail. # If you write # # your_test() { # parse_args "$@" # # $test_expectation "$cmd - behaves well" " # ... # $full_command && # ... # " # } # # then your test can be used like this: # # your_test expect_(success|failure) [test_must_fail] 'git foo' # proc parse_args { global test_expectation := ""test_$1"" shift if test $1 = test_must_fail { global full_command := '"test_must_fail test_terminal '" shift } else { global full_command := '"test_terminal '" } global cmd := $1 global full_command := ""$full_command $1"" } proc test_default_pager { parse_args @Argv $test_expectation SIMPLEPAGER,TTY "$cmd - default pager is used by default" " sane_unset PAGER GIT_PAGER && test_unconfig core.pager && rm -f default_pager_used && cat >\$less <<-\EOF && #!/bin/sh wc >default_pager_used EOF chmod +x \$less && ( PATH=.:\$PATH && export PATH && $full_command ) && test -e default_pager_used " } proc test_PAGER_overrides { parse_args @Argv $test_expectation TTY "$cmd - PAGER overrides default pager" " sane_unset GIT_PAGER && test_unconfig core.pager && rm -f PAGER_used && PAGER='wc >PAGER_used' && export PAGER && $full_command && test -e PAGER_used " } proc test_core_pager_overrides { global if_local_config := '' global used_if_wanted := ''overrides PAGER'' test_core_pager @Argv } proc test_local_config_ignored { global if_local_config := ''! '' global used_if_wanted := ''is not used'' test_core_pager @Argv } proc test_core_pager { parse_args @Argv $test_expectation TTY "$cmd - repository-local core.pager setting $used_if_wanted" " sane_unset GIT_PAGER && rm -f core.pager_used && PAGER=wc && export PAGER && test_config core.pager 'wc >core.pager_used' && $full_command && $(if_local_config)test -e core.pager_used " } proc test_core_pager_subdir { global if_local_config := '' global used_if_wanted := ''overrides PAGER'' test_pager_subdir_helper @Argv } proc test_no_local_config_subdir { global if_local_config := ''! '' global used_if_wanted := ''is not used'' test_pager_subdir_helper @Argv } proc test_pager_subdir_helper { parse_args @Argv $test_expectation TTY "$cmd - core.pager $used_if_wanted from subdirectory" " sane_unset GIT_PAGER && rm -f core.pager_used && rm -fr sub && PAGER=wc && stampname=\$(pwd)/core.pager_used && export PAGER stampname && test_config core.pager 'wc >\"\$stampname\"' && mkdir sub && ( cd sub && $full_command ) && $(if_local_config)test -e core.pager_used " } proc test_GIT_PAGER_overrides { parse_args @Argv $test_expectation TTY "$cmd - GIT_PAGER overrides core.pager" " rm -f GIT_PAGER_used && test_config core.pager wc && GIT_PAGER='wc >GIT_PAGER_used' && export GIT_PAGER && $full_command && test -e GIT_PAGER_used " } proc test_doesnt_paginate { parse_args @Argv $test_expectation TTY "no pager for '$cmd'" " rm -f GIT_PAGER_used && GIT_PAGER='wc >GIT_PAGER_used' && export GIT_PAGER && $full_command && ! test -e GIT_PAGER_used " } proc test_pager_choices { test_default_pager expect_success @Argv test_PAGER_overrides expect_success @Argv test_core_pager_overrides expect_success @Argv test_core_pager_subdir expect_success @Argv test_GIT_PAGER_overrides expect_success @Argv } test_expect_success 'setup: some aliases' ' git config alias.aliasedlog log && git config alias.true "!true" ' test_pager_choices 'git log' test_pager_choices 'git -p log' test_pager_choices 'git aliasedlog' test_default_pager expect_success 'git -p aliasedlog' test_PAGER_overrides expect_success 'git -p aliasedlog' test_core_pager_overrides expect_success 'git -p aliasedlog' test_core_pager_subdir expect_failure 'git -p aliasedlog' test_GIT_PAGER_overrides expect_success 'git -p aliasedlog' test_default_pager expect_success 'git -p true' test_PAGER_overrides expect_success 'git -p true' test_core_pager_overrides expect_success 'git -p true' test_core_pager_subdir expect_failure 'git -p true' test_GIT_PAGER_overrides expect_success 'git -p true' test_default_pager expect_success test_must_fail 'git -p request-pull' test_PAGER_overrides expect_success test_must_fail 'git -p request-pull' test_core_pager_overrides expect_success test_must_fail 'git -p request-pull' test_core_pager_subdir expect_failure test_must_fail 'git -p request-pull' test_GIT_PAGER_overrides expect_success test_must_fail 'git -p request-pull' test_default_pager expect_success test_must_fail 'git -p' test_PAGER_overrides expect_success test_must_fail 'git -p' test_local_config_ignored expect_failure test_must_fail 'git -p' test_no_local_config_subdir expect_success test_must_fail 'git -p' test_GIT_PAGER_overrides expect_success test_must_fail 'git -p' test_doesnt_paginate expect_failure test_must_fail 'git -p nonsense' test_pager_choices 'git shortlog' test_expect_success 'setup: configure shortlog not to paginate' ' git config pager.shortlog false ' test_doesnt_paginate expect_success 'git shortlog' 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 expect && >actual && test_unconfig core.pager && test_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' ' sane_unset PAGER GIT_PAGER && echo "foo:initial" >expect && >actual && test_config core.pager "exit 1" && test_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 && test_config pager.log "exit 1" && test_terminal git log --format=%s -1 && test_cmp expect actual ' test_expect_success 'setup external command' ' cat >git-external <<-\EOF && #!/bin/sh git "$@" EOF chmod +x git-external ' test_expect_success TTY 'command-specific pager works for external commands' ' sane_unset PAGER GIT_PAGER && echo "foo:initial" >expect && >actual && test_config pager.external "sed s/^/foo:/ >actual" && test_terminal git --exec-path="$(pwd)" external log --format=%s -1 && test_cmp expect actual ' test_expect_success TTY 'sub-commands of externals use their own pager' ' sane_unset PAGER GIT_PAGER && echo "foo:initial" >expect && >actual && test_config pager.log "sed s/^/foo:/ >actual" && test_terminal git --exec-path=. external log --format=%s -1 && test_cmp expect actual ' test_expect_success TTY 'external command pagers override sub-commands' ' sane_unset PAGER GIT_PAGER && >expect && >actual && test_config pager.external false && test_config pager.log "sed s/^/log:/ >actual" && test_terminal git --exec-path=. external log --format=%s -1 && test_cmp expect actual ' test_expect_success 'command with underscores does not complain' ' write_script git-under_score <<-\EOF && echo ok EOF git --exec-path=. under_score >actual 2>&1 && echo ok >expect && test_cmp expect actual ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"Test automatic use of a pager.">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (C {(.)} {(DQ ($ VSub_Name "$TEST_DIRECTORY")) (/lib-pager.sh)}) (C {(.)} {(DQ ($ VSub_Name "$TEST_DIRECTORY")) (/lib-terminal.sh)}) (C {(test_expect_success)} {(SQ )} { (SQ <"\n"> <"\tsane_unset GIT_PAGER GIT_PAGER_IN_USE &&\n"> <"\ttest_unconfig core.pager &&\n"> <"\n"> <"\tPAGER=\"cat >paginated.out\" &&\n"> <"\texport PAGER &&\n"> <"\n"> <"\ttest_commit initial\n"> ) } ) (C {(test_expect_success)} {(TTY)} {(SQ <"some commands use a pager">)} { (SQ <"\n"> <"\trm -f paginated.out &&\n"> <"\ttest_terminal git log &&\n"> <"\ttest -e paginated.out\n"> ) } ) (C {(test_expect_failure)} {(TTY)} {(SQ <"pager runs from subdir">)} { (SQ <"\n"> <"\techo subdir/paginated.out >expected &&\n"> <"\tmkdir -p subdir &&\n"> <"\trm -f paginated.out subdir/paginated.out &&\n"> <"\t(\n"> <"\t\tcd subdir &&\n"> <"\t\ttest_terminal git log\n"> <"\t) &&\n"> <"\t{\n"> <"\t\tls paginated.out subdir/paginated.out ||\n"> <"\t\t:\n"> <"\t} >actual &&\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(TTY)} {(SQ <"LESS and LV envvars are set for pagination">)} { (SQ <"\n"> <"\t(\n"> <"\t\tsane_unset LESS LV &&\n"> <"\t\tPAGER=\"env >pager-env.out; wc\" &&\n"> <"\t\texport PAGER &&\n"> <"\n"> <"\t\ttest_terminal git log\n"> <"\t) &&\n"> <"\tgrep ^LESS= pager-env.out &&\n"> <"\tgrep ^LV= pager-env.out\n"> ) } ) (C {(test_expect_success)} {(KW_Bang "!") (MINGW) (Lit_Comma ",") (TTY)} {(SQ <"LESS and LV envvars set by git-sh-setup">)} { (SQ <"\n"> <"\t(\n"> <"\t\tsane_unset LESS LV &&\n"> <"\t\tPAGER=\"env >pager-env.out; wc\" &&\n"> <"\t\texport PAGER &&\n"> <"\t\tPATH=\"$(git --exec-path):$PATH\" &&\n"> <"\t\texport PATH &&\n"> <"\t\ttest_terminal sh -c \". git-sh-setup && git_pager\"\n"> <"\t) &&\n"> <"\tgrep ^LESS= pager-env.out &&\n"> <"\tgrep ^LV= pager-env.out\n"> ) } ) (C {(test_expect_success)} {(TTY)} {(SQ <"some commands do not use a pager">)} { (SQ <"\n"> <"\trm -f paginated.out &&\n"> <"\ttest_terminal git rev-list HEAD &&\n"> <"\t! test -e paginated.out\n"> ) } ) (C {(test_expect_success)} {(SQ <"no pager when stdout is a pipe">)} { (SQ <"\n"> <"\trm -f paginated.out &&\n"> <"\tgit log | cat &&\n"> <"\t! test -e paginated.out\n"> ) } ) (C {(test_expect_success)} {(SQ <"no pager when stdout is a regular file">)} { (SQ <"\n"> <"\trm -f paginated.out &&\n"> <"\tgit log >file &&\n"> <"\t! test -e paginated.out\n"> ) } ) (C {(test_expect_success)} {(TTY)} {(SQ <"git --paginate rev-list uses a pager">)} { (SQ <"\n"> <"\trm -f paginated.out &&\n"> <"\ttest_terminal git --paginate rev-list HEAD &&\n"> <"\ttest -e paginated.out\n"> ) } ) (C {(test_expect_success)} {(SQ <"no pager even with --paginate when stdout is a pipe">)} { (SQ <"\n"> <"\trm -f file paginated.out &&\n"> <"\tgit --paginate log | cat &&\n"> <"\t! test -e paginated.out\n"> ) } ) (C {(test_expect_success)} {(TTY)} {(SQ <"no pager with --no-pager">)} { (SQ <"\n"> <"\trm -f paginated.out &&\n"> <"\ttest_terminal git --no-pager log &&\n"> <"\t! test -e paginated.out\n"> ) } ) (C {(test_expect_success)} {(TTY)} {(SQ <"configuration can disable pager">)} { (SQ <"\n"> <"\trm -f paginated.out &&\n"> <"\ttest_unconfig pager.grep &&\n"> <"\ttest_terminal git grep initial &&\n"> <"\ttest -e paginated.out &&\n"> <"\n"> <"\trm -f paginated.out &&\n"> <"\ttest_config pager.grep false &&\n"> <"\ttest_terminal git grep initial &&\n"> <"\t! test -e paginated.out\n"> ) } ) (C {(test_expect_success)} {(TTY)} {(SQ <"git config uses a pager if configured to">)} { (SQ <"\n"> <"\trm -f paginated.out &&\n"> <"\ttest_config pager.config true &&\n"> <"\ttest_terminal git config --list &&\n"> <"\ttest -e paginated.out\n"> ) } ) (C {(test_expect_success)} {(TTY)} {(SQ <"configuration can enable pager (from subdir)">)} { (SQ <"\n"> <"\trm -f paginated.out &&\n"> <"\tmkdir -p subdir &&\n"> <"\ttest_config pager.bundle true &&\n"> <"\n"> <"\tgit bundle create test.bundle --all &&\n"> <"\trm -f paginated.out subdir/paginated.out &&\n"> <"\t(\n"> <"\t\tcd subdir &&\n"> <"\t\ttest_terminal git bundle unbundle ../test.bundle\n"> <"\t) &&\n"> <"\t{\n"> <"\t\ttest -e paginated.out ||\n"> <"\t\ttest -e subdir/paginated.out\n"> <"\t}\n"> ) } ) (FuncDef name: colorful body: (BraceGroup children: [ (SimpleCommand words: [{(read)} {(firstline)}] redirects: [(Redir op_id:Redir_Less fd:-1 arg_word:{($ VSub_Number "$1")} spids:[309])] ) (Pipeline children: [ (SimpleCommand words: [{(expr)} {(DQ ($ VSub_Name "$firstline"))} {(Lit_Other ":")} {(DQ ("[a-zA-Z]"))}] redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(/dev/null)} spids:[327])] ) ] negated: True ) ] spids: [302] ) spids: [298 301] ) (C {(test_expect_success)} {(SQ <"tests can detect color">)} { (SQ <"\n"> <"\trm -f colorful.log colorless.log &&\n"> <"\tgit log --no-color >colorless.log &&\n"> <"\tgit log --color >colorful.log &&\n"> <"\t! colorful colorless.log &&\n"> <"\tcolorful colorful.log\n"> ) } ) (C {(test_expect_success)} {(SQ <"no color when stdout is a regular file">)} { (SQ <"\n"> <"\trm -f colorless.log &&\n"> <"\ttest_config color.ui auto &&\n"> <"\tgit log >colorless.log &&\n"> <"\t! colorful colorless.log\n"> ) } ) (C {(test_expect_success)} {(TTY)} {(SQ <"color when writing to a pager">)} { (SQ <"\n"> <"\trm -f paginated.out &&\n"> <"\ttest_config color.ui auto &&\n"> <"\ttest_terminal env TERM=vt100 git log &&\n"> <"\tcolorful paginated.out\n"> ) } ) (C {(test_expect_success)} {(TTY)} {(SQ <"colors are suppressed by color.pager">)} { (SQ <"\n"> <"\trm -f paginated.out &&\n"> <"\ttest_config color.ui auto &&\n"> <"\ttest_config color.pager false &&\n"> <"\ttest_terminal env TERM=vt100 git log &&\n"> <"\t! colorful paginated.out\n"> ) } ) (C {(test_expect_success)} {(SQ <"color when writing to a file intended for a pager">)} { (SQ <"\n"> <"\trm -f colorful.log &&\n"> <"\ttest_config color.ui auto &&\n"> <"\t(\n"> <"\t\tTERM=vt100 &&\n"> <"\t\tGIT_PAGER_IN_USE=true &&\n"> <"\t\texport TERM GIT_PAGER_IN_USE &&\n"> <"\t\tgit log >colorful.log\n"> <"\t) &&\n"> <"\tcolorful colorful.log\n"> ) } ) (C {(test_expect_success)} {(TTY)} {(SQ <"colors are sent to pager for external commands">)} { (SQ <"\n"> <"\ttest_config alias.externallog \"!git log\" &&\n"> <"\ttest_config color.ui auto &&\n"> <"\ttest_terminal env TERM=vt100 git -p externallog &&\n"> <"\tcolorful paginated.out\n"> ) } ) (FuncDef name: parse_args body: (BraceGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_expectation) op: Equal rhs: {(DQ (test_) ($ VSub_Number "$1"))} spids: [497] ) ] spids: [497] ) (C {(shift)}) (If arms: [ (if_arm cond: [(C {(test)} {(DQ ($ VSub_Number "$1"))} {(Lit_Other "=")} {(test_must_fail)})] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:full_command) op: Equal rhs: {(DQ ("test_must_fail test_terminal "))} spids: [523] ) ] spids: [523] ) (C {(shift)}) ] spids: [-1 520] ) ] else_action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:full_command) op: Equal rhs: {(DQ ("test_terminal "))} spids: [535] ) ] spids: [535] ) ] spids: [532 541] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:cmd) op: Equal rhs: {($ VSub_Number "$1")} spids: [544] ) ] spids: [544] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:full_command) op: Equal rhs: {(DQ ($ VSub_Name "$full_command") (" ") ($ VSub_Number "$1"))} spids: [548] ) ] spids: [548] ) ] spids: [494] ) spids: [490 493] ) (FuncDef name: test_default_pager body: (BraceGroup children: [ (C {(parse_args)} {(DQ ($ VSub_At "$@"))}) (C {($ VSub_Name "$test_expectation")} {(SIMPLEPAGER) (Lit_Comma ",") (TTY)} {(DQ ($ VSub_Name "$cmd") (" - default pager is used by default"))} { (DQ ("\n") ("\t\tsane_unset PAGER GIT_PAGER &&\n") ("\t\ttest_unconfig core.pager &&\n") ("\t\trm -f default_pager_used &&\n") ("\t\tcat >") (EscapedLiteralPart token:) ("less <<-") (EscapedLiteralPart token:) ("OF &&\n") ("\t\t#!/bin/sh\n") ("\t\twc >default_pager_used\n") ("\t\tEOF\n") ("\t\tchmod +x ") (EscapedLiteralPart token:) ("less &&\n") ("\t\t(\n") ("\t\t\tPATH=.:") (EscapedLiteralPart token:) ("PATH &&\n") ("\t\t\texport PATH &&\n") ("\t\t\t") ($ VSub_Name "$full_command") ("\n") ("\t\t) &&\n") ("\t\ttest -e default_pager_used\n") ("\t") ) } ) ] spids: [562] ) spids: [558 561] ) (FuncDef name: test_PAGER_overrides body: (BraceGroup children: [ (C {(parse_args)} {(DQ ($ VSub_At "$@"))}) (C {($ VSub_Name "$test_expectation")} {(TTY)} {(DQ ($ VSub_Name "$cmd") (" - PAGER overrides default pager"))} { (DQ ("\n") ("\t\tsane_unset GIT_PAGER &&\n") ("\t\ttest_unconfig core.pager &&\n") ("\t\trm -f PAGER_used &&\n") ("\t\tPAGER='wc >PAGER_used' &&\n") ("\t\texport PAGER &&\n") ("\t\t") ($ VSub_Name "$full_command") (" &&\n") ("\t\ttest -e PAGER_used\n") ("\t") ) } ) ] spids: [620] ) spids: [616 619] ) (FuncDef name: test_core_pager_overrides body: (BraceGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:if_local_config) op: Equal rhs: {(SQ )} spids: [664] ) ] spids: [664] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:used_if_wanted) op: Equal rhs: {(SQ <"overrides PAGER">)} spids: [667] ) ] spids: [667] ) (C {(test_core_pager)} {(DQ ($ VSub_At "$@"))}) ] spids: [661] ) spids: [657 660] ) (FuncDef name: test_local_config_ignored body: (BraceGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:if_local_config) op: Equal rhs: {(SQ <"! ">)} spids: [689] ) ] spids: [689] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:used_if_wanted) op: Equal rhs: {(SQ <"is not used">)} spids: [695] ) ] spids: [695] ) (C {(test_core_pager)} {(DQ ($ VSub_At "$@"))}) ] spids: [686] ) spids: [682 685] ) (FuncDef name: test_core_pager body: (BraceGroup children: [ (C {(parse_args)} {(DQ ($ VSub_At "$@"))}) (C {($ VSub_Name "$test_expectation")} {(TTY)} { (DQ ($ VSub_Name "$cmd") (" - repository-local core.pager setting ") ($ VSub_Name "$used_if_wanted") ) } { (DQ ("\n") ("\t\tsane_unset GIT_PAGER &&\n") ("\t\trm -f core.pager_used &&\n") ("\t\tPAGER=wc &&\n") ("\t\texport PAGER &&\n") ("\t\ttest_config core.pager 'wc >core.pager_used' &&\n") ("\t\t") ($ VSub_Name "$full_command") (" &&\n") ("\t\t") (${ VSub_Name if_local_config) ("test -e core.pager_used\n") ("\t") ) } ) ] spids: [714] ) spids: [710 713] ) (FuncDef name: test_core_pager_subdir body: (BraceGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:if_local_config) op: Equal rhs: {(SQ )} spids: [763] ) ] spids: [763] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:used_if_wanted) op: Equal rhs: {(SQ <"overrides PAGER">)} spids: [766] ) ] spids: [766] ) (C {(test_pager_subdir_helper)} {(DQ ($ VSub_At "$@"))}) ] spids: [760] ) spids: [756 759] ) (FuncDef name: test_no_local_config_subdir body: (BraceGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:if_local_config) op: Equal rhs: {(SQ <"! ">)} spids: [788] ) ] spids: [788] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:used_if_wanted) op: Equal rhs: {(SQ <"is not used">)} spids: [794] ) ] spids: [794] ) (C {(test_pager_subdir_helper)} {(DQ ($ VSub_At "$@"))}) ] spids: [785] ) spids: [781 784] ) (FuncDef name: test_pager_subdir_helper body: (BraceGroup children: [ (C {(parse_args)} {(DQ ($ VSub_At "$@"))}) (C {($ VSub_Name "$test_expectation")} {(TTY)} { (DQ ($ VSub_Name "$cmd") (" - core.pager ") ($ VSub_Name "$used_if_wanted") (" from subdirectory") ) } { (DQ ("\n") ("\t\tsane_unset GIT_PAGER &&\n") ("\t\trm -f core.pager_used &&\n") ("\t\trm -fr sub &&\n") ("\t\tPAGER=wc &&\n") ("\t\tstampname=") (EscapedLiteralPart token:) ("(pwd)/core.pager_used &&\n") ("\t\texport PAGER stampname &&\n") ("\t\ttest_config core.pager 'wc >") (EscapedLiteralPart token:) (EscapedLiteralPart token:) (stampname) (EscapedLiteralPart token:) ("' &&\n") ("\t\tmkdir sub &&\n") ("\t\t(\n") ("\t\t\tcd sub &&\n") ("\t\t\t") ($ VSub_Name "$full_command") ("\n") ("\t\t) &&\n") ("\t\t") (${ VSub_Name if_local_config) ("test -e core.pager_used\n") ("\t") ) } ) ] spids: [813] ) spids: [809 812] ) (FuncDef name: test_GIT_PAGER_overrides body: (BraceGroup children: [ (C {(parse_args)} {(DQ ($ VSub_At "$@"))}) (C {($ VSub_Name "$test_expectation")} {(TTY)} {(DQ ($ VSub_Name "$cmd") (" - GIT_PAGER overrides core.pager"))} { (DQ ("\n") ("\t\trm -f GIT_PAGER_used &&\n") ("\t\ttest_config core.pager wc &&\n") ("\t\tGIT_PAGER='wc >GIT_PAGER_used' &&\n") ("\t\texport GIT_PAGER &&\n") ("\t\t") ($ VSub_Name "$full_command") (" &&\n") ("\t\ttest -e GIT_PAGER_used\n") ("\t") ) } ) ] spids: [873] ) spids: [869 872] ) (FuncDef name: test_doesnt_paginate body: (BraceGroup children: [ (C {(parse_args)} {(DQ ($ VSub_At "$@"))}) (C {($ VSub_Name "$test_expectation")} {(TTY)} {(DQ ("no pager for '") ($ VSub_Name "$cmd") ("'"))} { (DQ ("\n") ("\t\trm -f GIT_PAGER_used &&\n") ("\t\tGIT_PAGER='wc >GIT_PAGER_used' &&\n") ("\t\texport GIT_PAGER &&\n") ("\t\t") ($ VSub_Name "$full_command") (" &&\n") ("\t\t! test -e GIT_PAGER_used\n") ("\t") ) } ) ] spids: [913] ) spids: [909 912] ) (FuncDef name: test_pager_choices body: (BraceGroup children: [ (C {(test_default_pager)} {(expect_success)} {(DQ ($ VSub_At "$@"))}) (C {(test_PAGER_overrides)} {(expect_success)} {(DQ ($ VSub_At "$@"))}) (C {(test_core_pager_overrides)} {(expect_success)} {(DQ ($ VSub_At "$@"))}) (C {(test_core_pager_subdir)} {(expect_success)} {(DQ ($ VSub_At "$@"))}) (C {(test_GIT_PAGER_overrides)} {(expect_success)} {(DQ ($ VSub_At "$@"))}) ] spids: [953] ) spids: [949 952] ) (C {(test_expect_success)} {(SQ <"setup: some aliases">)} { (SQ <"\n"> <"\tgit config alias.aliasedlog log &&\n"> <"\tgit config alias.true \"!true\"\n">) } ) (C {(test_pager_choices)} {(SQ <"git log">)}) (C {(test_pager_choices)} {(SQ <"git -p log">)}) (C {(test_pager_choices)} {(SQ <"git aliasedlog">)}) (C {(test_default_pager)} {(expect_success)} {(SQ <"git -p aliasedlog">)}) (C {(test_PAGER_overrides)} {(expect_success)} {(SQ <"git -p aliasedlog">)}) (C {(test_core_pager_overrides)} {(expect_success)} {(SQ <"git -p aliasedlog">)}) (C {(test_core_pager_subdir)} {(expect_failure)} {(SQ <"git -p aliasedlog">)}) (C {(test_GIT_PAGER_overrides)} {(expect_success)} {(SQ <"git -p aliasedlog">)}) (C {(test_default_pager)} {(expect_success)} {(SQ <"git -p true">)}) (C {(test_PAGER_overrides)} {(expect_success)} {(SQ <"git -p true">)}) (C {(test_core_pager_overrides)} {(expect_success)} {(SQ <"git -p true">)}) (C {(test_core_pager_subdir)} {(expect_failure)} {(SQ <"git -p true">)}) (C {(test_GIT_PAGER_overrides)} {(expect_success)} {(SQ <"git -p true">)}) (C {(test_default_pager)} {(expect_success)} {(test_must_fail)} {(SQ <"git -p request-pull">)}) (C {(test_PAGER_overrides)} {(expect_success)} {(test_must_fail)} {(SQ <"git -p request-pull">)}) (C {(test_core_pager_overrides)} {(expect_success)} {(test_must_fail)} {(SQ <"git -p request-pull">)}) (C {(test_core_pager_subdir)} {(expect_failure)} {(test_must_fail)} {(SQ <"git -p request-pull">)}) (C {(test_GIT_PAGER_overrides)} {(expect_success)} {(test_must_fail)} {(SQ <"git -p request-pull">)}) (C {(test_default_pager)} {(expect_success)} {(test_must_fail)} {(SQ <"git -p">)}) (C {(test_PAGER_overrides)} {(expect_success)} {(test_must_fail)} {(SQ <"git -p">)}) (C {(test_local_config_ignored)} {(expect_failure)} {(test_must_fail)} {(SQ <"git -p">)}) (C {(test_no_local_config_subdir)} {(expect_success)} {(test_must_fail)} {(SQ <"git -p">)}) (C {(test_GIT_PAGER_overrides)} {(expect_success)} {(test_must_fail)} {(SQ <"git -p">)}) (C {(test_doesnt_paginate)} {(expect_failure)} {(test_must_fail)} {(SQ <"git -p nonsense">)}) (C {(test_pager_choices)} {(SQ <"git shortlog">)}) (C {(test_expect_success)} {(SQ <"setup: configure shortlog not to paginate">)} {(SQ <"\n"> <"\tgit config pager.shortlog false\n">)} ) (C {(test_doesnt_paginate)} {(expect_success)} {(SQ <"git shortlog">)}) (C {(test_no_local_config_subdir)} {(expect_success)} {(SQ <"git shortlog">)}) (C {(test_default_pager)} {(expect_success)} {(SQ <"git -p shortlog">)}) (C {(test_core_pager_subdir)} {(expect_success)} {(SQ <"git -p shortlog">)}) (C {(test_core_pager_subdir)} {(expect_success)} {(test_must_fail)} {(SQ <"git -p apply )}) (C {(test_expect_success)} {(TTY)} {(SQ <"command-specific pager">)} { (SQ <"\n"> <"\tsane_unset PAGER GIT_PAGER &&\n"> <"\techo \"foo:initial\" >expect &&\n"> <"\t>actual &&\n"> <"\ttest_unconfig core.pager &&\n"> <"\ttest_config pager.log \"sed s/^/foo:/ >actual\" &&\n"> <"\ttest_terminal git log --format=%s -1 &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(TTY)} {(SQ <"command-specific pager overrides core.pager">)} { (SQ <"\n"> <"\tsane_unset PAGER GIT_PAGER &&\n"> <"\techo \"foo:initial\" >expect &&\n"> <"\t>actual &&\n"> <"\ttest_config core.pager \"exit 1\" &&\n"> <"\ttest_config pager.log \"sed s/^/foo:/ >actual\" &&\n"> <"\ttest_terminal git log --format=%s -1 &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(TTY)} {(SQ <"command-specific pager overridden by environment">)} { (SQ <"\n"> <"\tGIT_PAGER=\"sed s/^/foo:/ >actual\" && export GIT_PAGER &&\n"> <"\t>actual &&\n"> <"\techo \"foo:initial\" >expect &&\n"> <"\ttest_config pager.log \"exit 1\" &&\n"> <"\ttest_terminal git log --format=%s -1 &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"setup external command">)} { (SQ <"\n"> <"\tcat >git-external <<-\\EOF &&\n"> <"\t#!/bin/sh\n"> <"\tgit \"$@\"\n"> <"\tEOF\n"> <"\tchmod +x git-external\n"> ) } ) (C {(test_expect_success)} {(TTY)} {(SQ <"command-specific pager works for external commands">)} { (SQ <"\n"> <"\tsane_unset PAGER GIT_PAGER &&\n"> <"\techo \"foo:initial\" >expect &&\n"> <"\t>actual &&\n"> <"\ttest_config pager.external \"sed s/^/foo:/ >actual\" &&\n"> <"\ttest_terminal git --exec-path=\"$(pwd)\" external log --format=%s -1 &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(TTY)} {(SQ <"sub-commands of externals use their own pager">)} { (SQ <"\n"> <"\tsane_unset PAGER GIT_PAGER &&\n"> <"\techo \"foo:initial\" >expect &&\n"> <"\t>actual &&\n"> <"\ttest_config pager.log \"sed s/^/foo:/ >actual\" &&\n"> <"\ttest_terminal git --exec-path=. external log --format=%s -1 &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(TTY)} {(SQ <"external command pagers override sub-commands">)} { (SQ <"\n"> <"\tsane_unset PAGER GIT_PAGER &&\n"> <"\t>expect &&\n"> <"\t>actual &&\n"> <"\ttest_config pager.external false &&\n"> <"\ttest_config pager.log \"sed s/^/log:/ >actual\" &&\n"> <"\ttest_terminal git --exec-path=. external log --format=%s -1 &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"command with underscores does not complain">)} { (SQ <"\n"> <"\twrite_script git-under_score <<-\\EOF &&\n"> <"\techo ok\n"> <"\tEOF\n"> <"\tgit --exec-path=. under_score >actual 2>&1 &&\n"> <"\techo ok >expect &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_done)}) ] )