Skip to content

Commit 77a6815

Browse files
ashumkingitster
authored andcommitted
t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs
The expected SHA-1 digests are always available in variables. Use them instead of hardcoding. Signed-off-by: Alexey Shumkin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 362de91 commit 77a6815

File tree

1 file changed

+77
-63
lines changed

1 file changed

+77
-63
lines changed

t/t6006-rev-list-format.sh

Lines changed: 77 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,19 @@ test_description='git rev-list --pretty=format test'
77

88
test_tick
99
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)
1223
'
1324

1425
# usage: test_format name format_string <expected_output
@@ -32,108 +43,108 @@ has_no_color () {
3243
test_cmp expect "$1"
3344
}
3445

35-
test_format percent %%h <<'EOF'
36-
commit 131a310eb913d107dd3c09a65d1651175898735d
46+
test_format percent %%h <<EOF
47+
commit $head2
3748
%h
38-
commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
49+
commit $head1
3950
%h
4051
EOF
4152

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
4960
EOF
5061

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
5869
EOF
5970

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
6576
6677
6778
EOF
6879

6980
# 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
7283
A U Thor
7384
7485
Thu Apr 7 15:13:13 2005 -0700
7586
Thu, 7 Apr 2005 15:13:13 -0700
7687
1112911993
77-
commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
88+
commit $head1
7889
A U Thor
7990
8091
Thu Apr 7 15:13:13 2005 -0700
8192
Thu, 7 Apr 2005 15:13:13 -0700
8293
1112911993
8394
EOF
8495

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
8798
C O Mitter
8899
89100
Thu Apr 7 15:13:13 2005 -0700
90101
Thu, 7 Apr 2005 15:13:13 -0700
91102
1112911993
92-
commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
103+
commit $head1
93104
C O Mitter
94105
95106
Thu Apr 7 15:13:13 2005 -0700
96107
Thu, 7 Apr 2005 15:13:13 -0700
97108
1112911993
98109
EOF
99110

100-
test_format encoding %e <<'EOF'
101-
commit 131a310eb913d107dd3c09a65d1651175898735d
102-
commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
111+
test_format encoding %e <<EOF
112+
commit $head2
113+
commit $head1
103114
EOF
104115

105-
test_format subject %s <<'EOF'
106-
commit 131a310eb913d107dd3c09a65d1651175898735d
116+
test_format subject %s <<EOF
117+
commit $head2
107118
changed foo
108-
commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
119+
commit $head1
109120
added foo
110121
EOF
111122

112-
test_format body %b <<'EOF'
113-
commit 131a310eb913d107dd3c09a65d1651175898735d
114-
commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
123+
test_format body %b <<EOF
124+
commit $head2
125+
commit $head1
115126
EOF
116127

117-
test_format raw-body %B <<'EOF'
118-
commit 131a310eb913d107dd3c09a65d1651175898735d
128+
test_format raw-body %B <<EOF
129+
commit $head2
119130
changed foo
120131
121-
commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
132+
commit $head1
122133
added foo
123134
124135
EOF
125136

126-
test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<'EOF'
127-
commit 131a310eb913d107dd3c09a65d1651175898735d
137+
test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<EOF
138+
commit $head2
128139
foobarbazxyzzy
129-
commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
140+
commit $head1
130141
foobarbazxyzzy
131142
EOF
132143

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
135146
foo
136-
commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
147+
commit $head1
137148
foo
138149
EOF
139150

@@ -186,39 +197,42 @@ This commit message is much longer than the others,
186197
and it will be encoded in iso8859-1. We should therefore
187198
include an iso8859 character: ¡bueno!
188199
EOF
200+
189201
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)
192206
'
193207

194-
test_format complex-encoding %e <<'EOF'
195-
commit 1ed88da4a5b5ed8c449114ac131efc62178734c3
208+
test_format complex-encoding %e <<EOF
209+
commit $head3
196210
iso8859-1
197-
commit 131a310eb913d107dd3c09a65d1651175898735d
198-
commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
211+
commit $head2
212+
commit $head1
199213
EOF
200214

201-
test_format complex-subject %s <<'EOF'
202-
commit 1ed88da4a5b5ed8c449114ac131efc62178734c3
215+
test_format complex-subject %s <<EOF
216+
commit $head3
203217
Test printing of complex bodies
204-
commit 131a310eb913d107dd3c09a65d1651175898735d
218+
commit $head2
205219
changed foo
206-
commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
220+
commit $head1
207221
added foo
208222
EOF
209223

210-
test_format complex-body %b <<'EOF'
211-
commit 1ed88da4a5b5ed8c449114ac131efc62178734c3
224+
test_format complex-body %b <<EOF
225+
commit $head3
212226
This commit message is much longer than the others,
213227
and it will be encoded in iso8859-1. We should therefore
214228
include an iso8859 character: ¡bueno!
215229
216-
commit 131a310eb913d107dd3c09a65d1651175898735d
217-
commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
230+
commit $head2
231+
commit $head1
218232
EOF
219233

220234
test_expect_success '%x00 shows NUL' '
221-
echo >expect commit 1ed88da4a5b5ed8c449114ac131efc62178734c3 &&
235+
echo >expect commit $head3 &&
222236
echo >>expect fooQbar &&
223237
git rev-list -1 --format=foo%x00bar HEAD >actual.nul &&
224238
nul_to_q <actual.nul >actual &&

0 commit comments

Comments
 (0)