919b371169ac6c1eb3010f7bafa2685c19109013
1#!/bin/sh
2
3test_description='log --grep/--author/--regexp-ignore-case/-S/-G'
4. ./test-lib.sh
5
6test_log () {
7 expect=$1
8 kind=$2
9 needle=$3
10 shift 3
11 rest=$@
12
13 case $kind in
14 --*)
15 opt=$kind=$needle
16 ;;
17 *)
18 opt=$kind$needle
19 ;;
20 esac
21 case $expect in
22 expect_nomatch)
23 match=nomatch
24 ;;
25 *)
26 match=match
27 ;;
28 esac
29
30 test_expect_success "log $kind${rest:+ $rest} ($match)" "
31 git log $rest $opt --format=%H >actual &&
32 test_cmp $expect actual
33 "
34}
35
36# test -i and --regexp-ignore-case and expect both to behave the same way
37test_log_icase () {
38 test_log $@ --regexp-ignore-case
39 test_log $@ -i
40}
41
42test_expect_success setup '
43 >expect_nomatch &&
44
45 >file &&
46 git add file &&
47 test_tick &&
48 git commit -m initial &&
49 git rev-parse --verify HEAD >expect_initial &&
50
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
56'
57
58test_expect_success 'log --grep' '
59 git log --grep=initial --format=%H >actual &&
60 test_cmp expect_initial actual
61'
62
63test_expect_success 'log --grep --regexp-ignore-case' '
64 git log --regexp-ignore-case --grep=InItial --format=%H >actual &&
65 test_cmp expect_initial actual
66'
67
68test_expect_success 'log --grep -i' '
69 git log -i --grep=InItial --format=%H >actual &&
70 test_cmp expect_initial actual
71'
72
73test_expect_success 'log --author --regexp-ignore-case' '
74 git log --regexp-ignore-case --author=person --format=%H >actual &&
75 test_cmp expect_second actual
76'
77
78test_expect_success 'log --author -i' '
79 git log -i --author=person --format=%H >actual &&
80 test_cmp expect_second actual
81'
82
83test_log expect_nomatch -G picked
84test_log expect_second -G Picked
85test_log_icase expect_nomatch -G pickle
86test_log_icase expect_second -G picked
87
88test_expect_success 'log -G --textconv (missing textconv tool)' '
89 echo "* diff=test" >.gitattributes &&
90 test_must_fail git -c diff.test.textconv=missing log -Gfoo &&
91 rm .gitattributes
92'
93
94test_expect_success 'log -G --no-textconv (missing textconv tool)' '
95 echo "* diff=test" >.gitattributes &&
96 git -c diff.test.textconv=missing log -Gfoo --no-textconv >actual &&
97 test_cmp expect_nomatch actual &&
98 rm .gitattributes
99'
100
101test_log expect_nomatch -S picked
102test_log expect_second -S Picked
103test_log_icase expect_second -S picked
104test_log_icase expect_nomatch -S pickle
105
106test_expect_success 'log -S --textconv (missing textconv tool)' '
107 echo "* diff=test" >.gitattributes &&
108 test_must_fail git -c diff.test.textconv=missing log -Sfoo &&
109 rm .gitattributes
110'
111
112test_expect_success 'log -S --no-textconv (missing textconv tool)' '
113 echo "* diff=test" >.gitattributes &&
114 git -c diff.test.textconv=missing log -Sfoo --no-textconv >actual &&
115 test_cmp expect_nomatch actual &&
116 rm .gitattributes
117'
118
119test_done