(CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"git grep --open-files-in-pager\n">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (C {(.)} {(DQ ($ VSub_Name "$TEST_DIRECTORY")) (/lib-pager.sh)}) (C {(unset)} {(PAGER)} {(GIT_PAGER)}) (C {(test_expect_success)} {(SQ <setup>)} { (SQ <"\n"> <"\ttest_commit initial grep.h \"\n"> <"enum grep_pat_token {\n"> <"\tGREP_PATTERN,\n"> <"\tGREP_PATTERN_HEAD,\n"> <"\tGREP_PATTERN_BODY,\n"> <"\tGREP_AND,\n"> <"\tGREP_OPEN_PAREN,\n"> <"\tGREP_CLOSE_PAREN,\n"> <"\tGREP_NOT,\n"> <"\tGREP_OR,\n"> <"};\" &&\n"> <"\n"> <"\ttest_commit add-user revision.c \"\n"> <"\t}\n"> <"\tif (seen_dashdash)\n"> <"\t\tread_pathspec_from_stdin(revs, &sb, prune);\n"> <"\tstrbuf_release(&sb);\n"> <"}\n"> <"\n"> < "static void add_grep(struct rev_info *revs, const char *ptn, enum grep_pat_token what)\n" > <"{\n"> <"\tappend_grep_pattern(&revs->grep_filter, ptn, \\\"command line\\\", 0, what);\n"> <"\" &&\n"> <"\n"> <"\tmkdir subdir &&\n"> <"\ttest_commit subdir subdir/grep.c \"enum grep_pat_token\" &&\n"> <"\n"> <"\ttest_commit uninteresting unrelated \"hello, world\" &&\n"> <"\n"> <"\techo GREP_PATTERN >untracked\n"> ) } ) (C {(test_expect_success)} {(SIMPLEPAGER)} {(SQ <"git grep -O">)} { (SQ <"\n"> <"\tcat >$less <<-\\EOF &&\n"> <"\t#!/bin/sh\n"> <"\tprintf \"%s\\n\" \"$@\" >pager-args\n"> <"\tEOF\n"> <"\tchmod +x $less &&\n"> <"\tcat >expect.less <<-\\EOF &&\n"> <"\t+/*GREP_PATTERN\n"> <"\tgrep.h\n"> <"\tEOF\n"> <"\techo grep.h >expect.notless &&\n"> <"\t>empty &&\n"> <"\n"> <"\tPATH=.:$PATH git grep -O GREP_PATTERN >out &&\n"> <"\t{\n"> <"\t\ttest_cmp expect.less pager-args ||\n"> <"\t\ttest_cmp expect.notless pager-args\n"> <"\t} &&\n"> <"\ttest_cmp empty out\n"> ) } ) (C {(test_expect_success)} {(SQ <"git grep -O --cached">)} { (SQ <"\n"> <"\ttest_must_fail git grep --cached -O GREP_PATTERN >out 2>msg &&\n"> <"\ttest_i18ngrep open-files-in-pager msg\n"> ) } ) (C {(test_expect_success)} {(SQ <"git grep -O --no-index">)} { (SQ <"\n"> <"\trm -f expect.less pager-args out &&\n"> <"\tcat >expect <<-\\EOF &&\n"> <"\tgrep.h\n"> <"\tuntracked\n"> <"\tEOF\n"> <"\t>empty &&\n"> <"\n"> <"\t(\n"> <"\t\tGIT_PAGER="> ) (EscapedLiteralPart token:<Lit_EscapedChar "\\'">) (SQ <"printf \"%s\\n\" >pager-args">) (EscapedLiteralPart token:<Lit_EscapedChar "\\'">) (SQ <" &&\n"> <"\t\texport GIT_PAGER &&\n"> <"\t\tgit grep --no-index -O GREP_PATTERN >out\n"> <"\t) &&\n"> <"\ttest_cmp expect pager-args &&\n"> <"\ttest_cmp empty out\n"> ) } ) (C {(test_expect_success)} {(SQ <"setup: fake \"less\"">)} { (SQ <"\n"> <"\tcat >less <<-\\EOF &&\n"> <"\t#!/bin/sh\n"> <"\tprintf \"%s\\n\" \"$@\" >actual\n"> <"\tEOF\n"> <"\tchmod +x less\n"> ) } ) (C {(test_expect_success)} {(SQ <"git grep -O jumps to line in less">)} { (SQ <"\n"> <"\tcat >expect <<-\\EOF &&\n"> <"\t+/*GREP_PATTERN\n"> <"\tgrep.h\n"> <"\tEOF\n"> <"\t>empty &&\n"> <"\n"> <"\tGIT_PAGER=./less git grep -O GREP_PATTERN >out &&\n"> <"\ttest_cmp expect actual &&\n"> <"\ttest_cmp empty out &&\n"> <"\n"> <"\tgit grep -O./less GREP_PATTERN >out2 &&\n"> <"\ttest_cmp expect actual &&\n"> <"\ttest_cmp empty out2\n"> ) } ) (C {(test_expect_success)} {(SQ <"modified file">)} { (SQ <"\n"> <"\trm -f actual &&\n"> <"\tcat >expect <<-\\EOF &&\n"> <"\t+/*enum grep_pat_token\n"> <"\tgrep.h\n"> <"\trevision.c\n"> <"\tsubdir/grep.c\n"> <"\tunrelated\n"> <"\tEOF\n"> <"\t>empty &&\n"> <"\n"> <"\techo \"enum grep_pat_token\" >unrelated &&\n"> <"\ttest_when_finished \"git checkout HEAD unrelated\" &&\n"> <"\tGIT_PAGER=./less git grep -F -O \"enum grep_pat_token\" >out &&\n"> <"\ttest_cmp expect actual &&\n"> <"\ttest_cmp empty out\n"> ) } ) (C {(test_expect_success)} {(SQ <"copes with color settings">)} { (SQ <"\n"> <"\trm -f actual &&\n"> <"\techo grep.h >expect &&\n"> <"\ttest_config color.grep always &&\n"> <"\ttest_config color.grep.filename yellow &&\n"> <"\ttest_config color.grep.separator green &&\n"> <"\tgit grep -O"> ) (EscapedLiteralPart token:<Lit_EscapedChar "\\'">) (SQ <"printf \"%s\\n\" >actual">) (EscapedLiteralPart token:<Lit_EscapedChar "\\'">) (SQ <" GREP_AND &&\n"> <"\ttest_cmp expect actual\n">) } ) (C {(test_expect_success)} {(SQ <"run from subdir">)} { (SQ <"\n"> <"\trm -f actual &&\n"> <"\techo grep.c >expect &&\n"> <"\t>empty &&\n"> <"\n"> <"\t(\n"> <"\t\tcd subdir &&\n"> <"\t\texport GIT_PAGER &&\n"> <"\t\tGIT_PAGER="> ) (EscapedLiteralPart token:<Lit_EscapedChar "\\'">) (SQ <"printf \"%s\\n\" >../args">) (EscapedLiteralPart token:<Lit_EscapedChar "\\'">) (SQ <" &&\n"> <"\t\tgit grep -O \"enum grep_pat_token\" >../out &&\n"> <"\t\tgit grep -O\"pwd >../dir; :\" \"enum grep_pat_token\" >../out2\n"> <"\t) &&\n"> <"\tcase $(cat dir) in\n"> <"\t*subdir)\n"> <"\t\t: good\n"> <"\t\t;;\n"> <"\t*)\n"> <"\t\tfalse\n"> <"\t\t;;\n"> <"\tesac &&\n"> <"\ttest_cmp expect args &&\n"> <"\ttest_cmp empty out &&\n"> <"\ttest_cmp empty out2\n"> ) } ) (C {(test_done)}) ] )