@@ -7,8 +7,19 @@ test_description='git rev-list --pretty=format test'
7
7
8
8
test_tick
9
9
test_expect_success ' setup' '
10
- touch foo && git add foo && git commit -m "added foo" &&
11
- echo changed >foo && git commit -a -m "changed foo"
10
+ : >foo &&
11
+ git add foo &&
12
+ git commit -m "added foo" &&
13
+ head1=$(git rev-parse --verify HEAD) &&
14
+ head1_short=$(git rev-parse --verify --short $head1) &&
15
+ tree1=$(git rev-parse --verify HEAD:) &&
16
+ tree1_short=$(git rev-parse --verify --short $tree1) &&
17
+ echo changed >foo &&
18
+ git commit -a -m "changed foo" &&
19
+ head2=$(git rev-parse --verify HEAD) &&
20
+ head2_short=$(git rev-parse --verify --short $head2) &&
21
+ tree2=$(git rev-parse --verify HEAD:) &&
22
+ tree2_short=$(git rev-parse --verify --short $tree2)
12
23
'
13
24
14
25
# usage: test_format name format_string <expected_output
@@ -32,108 +43,108 @@ has_no_color () {
32
43
test_cmp expect " $1 "
33
44
}
34
45
35
- test_format percent %%h << ' EOF '
36
- commit 131a310eb913d107dd3c09a65d1651175898735d
46
+ test_format percent %%h << EOF
47
+ commit $head2
37
48
%h
38
- commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
49
+ commit $head1
39
50
%h
40
51
EOF
41
52
42
- test_format hash %H%n%h << ' EOF '
43
- commit 131a310eb913d107dd3c09a65d1651175898735d
44
- 131a310eb913d107dd3c09a65d1651175898735d
45
- 131a310
46
- commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
47
- 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
48
- 86c75cf
53
+ test_format hash %H%n%h << EOF
54
+ commit $head2
55
+ $head2
56
+ $head2_short
57
+ commit $head1
58
+ $head1
59
+ $head1_short
49
60
EOF
50
61
51
- test_format tree %T%n%t << ' EOF '
52
- commit 131a310eb913d107dd3c09a65d1651175898735d
53
- fe722612f26da5064c32ca3843aa154bdb0b08a0
54
- fe72261
55
- commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
56
- 4d5fcadc293a348e88f777dc0920f11e7d71441c
57
- 4d5fcad
62
+ test_format tree %T%n%t << EOF
63
+ commit $head2
64
+ $tree2
65
+ $tree2_short
66
+ commit $head1
67
+ $tree1
68
+ $tree1_short
58
69
EOF
59
70
60
- test_format parents %P%n%p << ' EOF '
61
- commit 131a310eb913d107dd3c09a65d1651175898735d
62
- 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
63
- 86c75cf
64
- commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
71
+ test_format parents %P%n%p << EOF
72
+ commit $head2
73
+ $head1
74
+ $head1_short
75
+ commit $head1
65
76
66
77
67
78
EOF
68
79
69
80
# we don't test relative here
70
- test_format author %an%n%ae%n%ad%n%aD%n%at << ' EOF '
71
- commit 131a310eb913d107dd3c09a65d1651175898735d
81
+ test_format author %an%n%ae%n%ad%n%aD%n%at << EOF
82
+ commit $head2
72
83
A U Thor
73
84
74
85
Thu Apr 7 15:13:13 2005 -0700
75
86
Thu, 7 Apr 2005 15:13:13 -0700
76
87
1112911993
77
- commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
88
+ commit $head1
78
89
A U Thor
79
90
80
91
Thu Apr 7 15:13:13 2005 -0700
81
92
Thu, 7 Apr 2005 15:13:13 -0700
82
93
1112911993
83
94
EOF
84
95
85
- test_format committer %cn%n%ce%n%cd%n%cD%n%ct << ' EOF '
86
- commit 131a310eb913d107dd3c09a65d1651175898735d
96
+ test_format committer %cn%n%ce%n%cd%n%cD%n%ct << EOF
97
+ commit $head2
87
98
C O Mitter
88
99
89
100
Thu Apr 7 15:13:13 2005 -0700
90
101
Thu, 7 Apr 2005 15:13:13 -0700
91
102
1112911993
92
- commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
103
+ commit $head1
93
104
C O Mitter
94
105
95
106
Thu Apr 7 15:13:13 2005 -0700
96
107
Thu, 7 Apr 2005 15:13:13 -0700
97
108
1112911993
98
109
EOF
99
110
100
- test_format encoding %e << ' EOF '
101
- commit 131a310eb913d107dd3c09a65d1651175898735d
102
- commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
111
+ test_format encoding %e << EOF
112
+ commit $head2
113
+ commit $head1
103
114
EOF
104
115
105
- test_format subject %s << ' EOF '
106
- commit 131a310eb913d107dd3c09a65d1651175898735d
116
+ test_format subject %s << EOF
117
+ commit $head2
107
118
changed foo
108
- commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
119
+ commit $head1
109
120
added foo
110
121
EOF
111
122
112
- test_format body %b << ' EOF '
113
- commit 131a310eb913d107dd3c09a65d1651175898735d
114
- commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
123
+ test_format body %b << EOF
124
+ commit $head2
125
+ commit $head1
115
126
EOF
116
127
117
- test_format raw-body %B << ' EOF '
118
- commit 131a310eb913d107dd3c09a65d1651175898735d
128
+ test_format raw-body %B << EOF
129
+ commit $head2
119
130
changed foo
120
131
121
- commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
132
+ commit $head1
122
133
added foo
123
134
124
135
EOF
125
136
126
- test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy << ' EOF '
127
- commit 131a310eb913d107dd3c09a65d1651175898735d
137
+ test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy << EOF
138
+ commit $head2
128
139
[31mfoo[32mbar[34mbaz[mxyzzy
129
- commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
140
+ commit $head1
130
141
[31mfoo[32mbar[34mbaz[mxyzzy
131
142
EOF
132
143
133
- test_format advanced-colors ' %C(red yellow bold)foo%C(reset)' << ' EOF '
134
- commit 131a310eb913d107dd3c09a65d1651175898735d
144
+ test_format advanced-colors ' %C(red yellow bold)foo%C(reset)' << EOF
145
+ commit $head2
135
146
[1;31;43mfoo[m
136
- commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
147
+ commit $head1
137
148
[1;31;43mfoo[m
138
149
EOF
139
150
@@ -186,39 +197,42 @@ This commit message is much longer than the others,
186
197
and it will be encoded in iso8859-1. We should therefore
187
198
include an iso8859 character: ¡bueno!
188
199
EOF
200
+
189
201
test_expect_success ' setup complex body' '
190
- git config i18n.commitencoding iso8859-1 &&
191
- echo change2 >foo && git commit -a -F commit-msg
202
+ git config i18n.commitencoding iso8859-1 &&
203
+ echo change2 >foo && git commit -a -F commit-msg &&
204
+ head3=$(git rev-parse --verify HEAD) &&
205
+ head3_short=$(git rev-parse --short $head3)
192
206
'
193
207
194
- test_format complex-encoding %e << ' EOF '
195
- commit 1ed88da4a5b5ed8c449114ac131efc62178734c3
208
+ test_format complex-encoding %e << EOF
209
+ commit $head3
196
210
iso8859-1
197
- commit 131a310eb913d107dd3c09a65d1651175898735d
198
- commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
211
+ commit $head2
212
+ commit $head1
199
213
EOF
200
214
201
- test_format complex-subject %s << ' EOF '
202
- commit 1ed88da4a5b5ed8c449114ac131efc62178734c3
215
+ test_format complex-subject %s << EOF
216
+ commit $head3
203
217
Test printing of complex bodies
204
- commit 131a310eb913d107dd3c09a65d1651175898735d
218
+ commit $head2
205
219
changed foo
206
- commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
220
+ commit $head1
207
221
added foo
208
222
EOF
209
223
210
- test_format complex-body %b << ' EOF '
211
- commit 1ed88da4a5b5ed8c449114ac131efc62178734c3
224
+ test_format complex-body %b << EOF
225
+ commit $head3
212
226
This commit message is much longer than the others,
213
227
and it will be encoded in iso8859-1. We should therefore
214
228
include an iso8859 character: ¡bueno!
215
229
216
- commit 131a310eb913d107dd3c09a65d1651175898735d
217
- commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
230
+ commit $head2
231
+ commit $head1
218
232
EOF
219
233
220
234
test_expect_success ' %x00 shows NUL' '
221
- echo >expect commit 1ed88da4a5b5ed8c449114ac131efc62178734c3 &&
235
+ echo >expect commit $head3 &&
222
236
echo >>expect fooQbar &&
223
237
git rev-list -1 --format=foo%x00bar HEAD >actual.nul &&
224
238
nul_to_q <actual.nul >actual &&
0 commit comments