t4209: use helper functions to test --grep
[git.git] / t / t4209-log-pickaxe.sh
blobeaa14a057cf84f85e07023a341b7750c08af6a3c
1 #!/bin/sh
3 test_description='log --grep/--author/--regexp-ignore-case/-S/-G'
4 . ./test-lib.sh
6 test_log () {
7 expect=$1
8 kind=$2
9 needle=$3
10 shift 3
11 rest=$@
13 case $kind in
14 --*)
15 opt=$kind=$needle
18 opt=$kind$needle
20 esac
21 case $expect in
22 expect_nomatch)
23 match=nomatch
26 match=match
28 esac
30 test_expect_success "log $kind${rest:+ $rest} ($match)" "
31 git log $rest $opt --format=%H >actual &&
32 test_cmp $expect actual
36 # test -i and --regexp-ignore-case and expect both to behave the same way
37 test_log_icase () {
38 test_log $@ --regexp-ignore-case
39 test_log $@ -i
42 test_expect_success setup '
43 >expect_nomatch &&
45 >file &&
46 git add file &&
47 test_tick &&
48 git commit -m initial &&
49 git rev-parse --verify HEAD >expect_initial &&
51 echo Picked >file &&
52 git add file &&
53 test_tick &&
54 git commit --author="Another Person <another@example.com>" -m second &&
55 git rev-parse --verify HEAD >expect_second
58 test_log expect_initial --grep initial
59 test_log expect_nomatch --grep InItial
60 test_log_icase expect_initial --grep InItial
61 test_log_icase expect_nomatch --grep initail
63 test_expect_success 'log --author --regexp-ignore-case' '
64 git log --regexp-ignore-case --author=person --format=%H >actual &&
65 test_cmp expect_second actual
68 test_expect_success 'log --author -i' '
69 git log -i --author=person --format=%H >actual &&
70 test_cmp expect_second actual
73 test_log expect_nomatch -G picked
74 test_log expect_second -G Picked
75 test_log_icase expect_nomatch -G pickle
76 test_log_icase expect_second -G picked
78 test_expect_success 'log -G --textconv (missing textconv tool)' '
79 echo "* diff=test" >.gitattributes &&
80 test_must_fail git -c diff.test.textconv=missing log -Gfoo &&
81 rm .gitattributes
84 test_expect_success 'log -G --no-textconv (missing textconv tool)' '
85 echo "* diff=test" >.gitattributes &&
86 git -c diff.test.textconv=missing log -Gfoo --no-textconv >actual &&
87 test_cmp expect_nomatch actual &&
88 rm .gitattributes
91 test_log expect_nomatch -S picked
92 test_log expect_second -S Picked
93 test_log_icase expect_second -S picked
94 test_log_icase expect_nomatch -S pickle
96 test_expect_success 'log -S --textconv (missing textconv tool)' '
97 echo "* diff=test" >.gitattributes &&
98 test_must_fail git -c diff.test.textconv=missing log -Sfoo &&
99 rm .gitattributes
102 test_expect_success 'log -S --no-textconv (missing textconv tool)' '
103 echo "* diff=test" >.gitattributes &&
104 git -c diff.test.textconv=missing log -Sfoo --no-textconv >actual &&
105 test_cmp expect_nomatch actual &&
106 rm .gitattributes
109 test_done