#!/bin/sh global test_description := ''log --grep/--author/--regexp-ignore-case/-S/-G'' source ./test-lib.sh proc test_log { global expect := $1 global kind := $2 global needle := $3 shift 3 global rest := $ifsjoin(Argv) matchstr $kind { --* { global opt := "$kind=$needle" } * { global opt := "$kind$needle" } } matchstr $expect { expect_nomatch { global match := 'nomatch' } * { global match := 'match' } } test_expect_success "log $kind$(rest:+ $rest) ($match)" " git log $rest $opt --format=%H >actual && test_cmp $expect actual " } # test -i and --regexp-ignore-case and expect both to behave the same way proc test_log_icase { test_log $ifsjoin(Argv) --regexp-ignore-case test_log $ifsjoin(Argv) -i } test_expect_success setup ' >expect_nomatch && >file && git add file && test_tick && git commit -m initial && git rev-parse --verify HEAD >expect_initial && echo Picked >file && git add file && test_tick && git commit --author="Another Person " -m second && git rev-parse --verify HEAD >expect_second ' test_log expect_initial --grep initial test_log expect_nomatch --grep InItial test_log_icase expect_initial --grep InItial test_log_icase expect_nomatch --grep initail test_log expect_second --author Person test_log expect_nomatch --author person test_log_icase expect_second --author person test_log_icase expect_nomatch --author spreon test_log expect_nomatch -G picked test_log expect_second -G Picked test_log_icase expect_nomatch -G pickle test_log_icase expect_second -G picked test_expect_success 'log -G --textconv (missing textconv tool)' ' echo "* diff=test" >.gitattributes && test_must_fail git -c diff.test.textconv=missing log -Gfoo && rm .gitattributes ' test_expect_success 'log -G --no-textconv (missing textconv tool)' ' echo "* diff=test" >.gitattributes && git -c diff.test.textconv=missing log -Gfoo --no-textconv >actual && test_cmp expect_nomatch actual && rm .gitattributes ' test_log expect_nomatch -S picked test_log expect_second -S Picked test_log_icase expect_second -S picked test_log_icase expect_nomatch -S pickle test_log expect_nomatch -S p.cked --pickaxe-regex test_log expect_second -S P.cked --pickaxe-regex test_log_icase expect_second -S p.cked --pickaxe-regex test_log_icase expect_nomatch -S p.ckle --pickaxe-regex test_expect_success 'log -S --textconv (missing textconv tool)' ' echo "* diff=test" >.gitattributes && test_must_fail git -c diff.test.textconv=missing log -Sfoo && rm .gitattributes ' test_expect_success 'log -S --no-textconv (missing textconv tool)' ' echo "* diff=test" >.gitattributes && git -c diff.test.textconv=missing log -Sfoo --no-textconv >actual && test_cmp expect_nomatch actual && rm .gitattributes ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"log --grep/--author/--regexp-ignore-case/-S/-G">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (FuncDef name: test_log body: (BraceGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:expect) op: Equal rhs: {($ VSub_Number "$1")} spids: [22] ) ] spids: [22] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:kind) op: Equal rhs: {($ VSub_Number "$2")} spids: [26] ) ] spids: [26] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:needle) op: Equal rhs: {($ VSub_Number "$3")} spids: [30] ) ] spids: [30] ) (C {(shift)} {(3)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:rest) op: Equal rhs: {($ VSub_At "$@")} spids: [39] ) ] spids: [39] ) (Case to_match: {($ VSub_Name "$kind")} arms: [ (case_arm pat_list: [{(--) (Lit_Other "*")}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:opt) op: Equal rhs: {($ VSub_Name "$kind") (Lit_Other "=") ($ VSub_Name "$needle")} spids: [56] ) ] spids: [56] ) ] spids: [51 53 62 -1] ) (case_arm pat_list: [{(Lit_Other "*")}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:opt) op: Equal rhs: {($ VSub_Name "$kind") ($ VSub_Name "$needle")} spids: [69] ) ] spids: [69] ) ] spids: [65 66 74 -1] ) ] spids: [44 48 77] ) (Case to_match: {($ VSub_Name "$expect")} arms: [ (case_arm pat_list: [{(expect_nomatch)}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:match) op: Equal rhs: {(nomatch)} spids: [91] ) ] spids: [91] ) ] spids: [87 88 95 -1] ) (case_arm pat_list: [{(Lit_Other "*")}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:match) op: Equal rhs: {(match)} spids: [102] ) ] spids: [102] ) ] spids: [98 99 106 -1] ) ] spids: [80 84 109] ) (C {(test_expect_success)} { (DQ ("log ") ($ VSub_Name "$kind") (BracedVarSub token: suffix_op: (StringUnary op_id: VTest_ColonPlus arg_word: {(" ") ($ VSub_Name "$rest")} ) spids: [118 123] ) (" (") ($ VSub_Name "$match") (")") ) } { (DQ ("\n") ("\t\tgit log ") ($ VSub_Name "$rest") (" ") ($ VSub_Name "$opt") (" --format=%H >actual &&\n") ("\t\ttest_cmp ") ($ VSub_Name "$expect") (" actual\n") ("\t") ) } ) ] spids: [19] ) spids: [14 18] ) (FuncDef name: test_log_icase body: (BraceGroup children: [ (C {(test_log)} {($ VSub_At "$@")} {(--regexp-ignore-case)}) (C {(test_log)} {($ VSub_At "$@")} {(-i)}) ] spids: [153] ) spids: [148 152] ) (C {(test_expect_success)} {(setup)} { (SQ <"\n"> <"\t>expect_nomatch &&\n"> <"\n"> <"\t>file &&\n"> <"\tgit add file &&\n"> <"\ttest_tick &&\n"> <"\tgit commit -m initial &&\n"> <"\tgit rev-parse --verify HEAD >expect_initial &&\n"> <"\n"> <"\techo Picked >file &&\n"> <"\tgit add file &&\n"> <"\ttest_tick &&\n"> <"\tgit commit --author=\"Another Person \" -m second &&\n"> <"\tgit rev-parse --verify HEAD >expect_second\n"> ) } ) (C {(test_log)} {(expect_initial)} {(--grep)} {(initial)}) (C {(test_log)} {(expect_nomatch)} {(--grep)} {(InItial)}) (C {(test_log_icase)} {(expect_initial)} {(--grep)} {(InItial)}) (C {(test_log_icase)} {(expect_nomatch)} {(--grep)} {(initail)}) (C {(test_log)} {(expect_second)} {(--author)} {(Person)}) (C {(test_log)} {(expect_nomatch)} {(--author)} {(person)}) (C {(test_log_icase)} {(expect_second)} {(--author)} {(person)}) (C {(test_log_icase)} {(expect_nomatch)} {(--author)} {(spreon)}) (C {(test_log)} {(expect_nomatch)} {(-G)} {(picked)}) (C {(test_log)} {(expect_second)} {(-G)} {(Picked)}) (C {(test_log_icase)} {(expect_nomatch)} {(-G)} {(pickle)}) (C {(test_log_icase)} {(expect_second)} {(-G)} {(picked)}) (C {(test_expect_success)} {(SQ <"log -G --textconv (missing textconv tool)">)} { (SQ <"\n"> <"\techo \"* diff=test\" >.gitattributes &&\n"> <"\ttest_must_fail git -c diff.test.textconv=missing log -Gfoo &&\n"> <"\trm .gitattributes\n"> ) } ) (C {(test_expect_success)} {(SQ <"log -G --no-textconv (missing textconv tool)">)} { (SQ <"\n"> <"\techo \"* diff=test\" >.gitattributes &&\n"> <"\tgit -c diff.test.textconv=missing log -Gfoo --no-textconv >actual &&\n"> <"\ttest_cmp expect_nomatch actual &&\n"> <"\trm .gitattributes\n"> ) } ) (C {(test_log)} {(expect_nomatch)} {(-S)} {(picked)}) (C {(test_log)} {(expect_second)} {(-S)} {(Picked)}) (C {(test_log_icase)} {(expect_second)} {(-S)} {(picked)}) (C {(test_log_icase)} {(expect_nomatch)} {(-S)} {(pickle)}) (C {(test_log)} {(expect_nomatch)} {(-S)} {(p.cked)} {(--pickaxe-regex)}) (C {(test_log)} {(expect_second)} {(-S)} {(P.cked)} {(--pickaxe-regex)}) (C {(test_log_icase)} {(expect_second)} {(-S)} {(p.cked)} {(--pickaxe-regex)}) (C {(test_log_icase)} {(expect_nomatch)} {(-S)} {(p.ckle)} {(--pickaxe-regex)}) (C {(test_expect_success)} {(SQ <"log -S --textconv (missing textconv tool)">)} { (SQ <"\n"> <"\techo \"* diff=test\" >.gitattributes &&\n"> <"\ttest_must_fail git -c diff.test.textconv=missing log -Sfoo &&\n"> <"\trm .gitattributes\n"> ) } ) (C {(test_expect_success)} {(SQ <"log -S --no-textconv (missing textconv tool)">)} { (SQ <"\n"> <"\techo \"* diff=test\" >.gitattributes &&\n"> <"\tgit -c diff.test.textconv=missing log -Sfoo --no-textconv >actual &&\n"> <"\ttest_cmp expect_nomatch actual &&\n"> <"\trm .gitattributes\n"> ) } ) (C {(test_done)}) ] )