t4209: factor out helper function test_log()
[git/raj.git] / t / t4209-log-pickaxe.sh
blob9c3b5963669dc0afde9a11737b9579fd1e2131e2
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_expect_success setup '
37 >expect_nomatch &&
39 >file &&
40 git add file &&
41 test_tick &&
42 git commit -m initial &&
43 git rev-parse --verify HEAD >expect_initial &&
45 echo Picked >file &&
46 git add file &&
47 test_tick &&
48 git commit --author="Another Person <another@example.com>" -m second &&
49 git rev-parse --verify HEAD >expect_second
52 test_expect_success 'log --grep' '
53 git log --grep=initial --format=%H >actual &&
54 test_cmp expect_initial actual
57 test_expect_success 'log --grep --regexp-ignore-case' '
58 git log --regexp-ignore-case --grep=InItial --format=%H >actual &&
59 test_cmp expect_initial actual
62 test_expect_success 'log --grep -i' '
63 git log -i --grep=InItial --format=%H >actual &&
64 test_cmp expect_initial actual
67 test_expect_success 'log --author --regexp-ignore-case' '
68 git log --regexp-ignore-case --author=person --format=%H >actual &&
69 test_cmp expect_second actual
72 test_expect_success 'log --author -i' '
73 git log -i --author=person --format=%H >actual &&
74 test_cmp expect_second actual
77 test_log expect_nomatch -G picked
78 test_log expect_second -G Picked
79 test_log expect_nomatch -G pickle --regexp-ignore-case
80 test_log expect_nomatch -G pickle -i
81 test_log expect_second -G picked --regexp-ignore-case
82 test_log expect_second -G picked -i
84 test_expect_success 'log -G --textconv (missing textconv tool)' '
85 echo "* diff=test" >.gitattributes &&
86 test_must_fail git -c diff.test.textconv=missing log -Gfoo &&
87 rm .gitattributes
90 test_expect_success 'log -G --no-textconv (missing textconv tool)' '
91 echo "* diff=test" >.gitattributes &&
92 git -c diff.test.textconv=missing log -Gfoo --no-textconv >actual &&
93 test_cmp expect_nomatch actual &&
94 rm .gitattributes
97 test_log expect_nomatch -S picked
98 test_log expect_second -S Picked
99 test_log expect_second -S picked --regexp-ignore-case
100 test_log expect_second -S picked -i
101 test_log expect_nomatch -S pickle --regexp-ignore-case
102 test_log expect_nomatch -S pickle -i
104 test_expect_success 'log -S --textconv (missing textconv tool)' '
105 echo "* diff=test" >.gitattributes &&
106 test_must_fail git -c diff.test.textconv=missing log -Sfoo &&
107 rm .gitattributes
110 test_expect_success 'log -S --no-textconv (missing textconv tool)' '
111 echo "* diff=test" >.gitattributes &&
112 git -c diff.test.textconv=missing log -Sfoo --no-textconv >actual &&
113 test_cmp expect_nomatch actual &&
114 rm .gitattributes
117 test_done