Skip to content

Commit fa26d5e

Browse files
bk2204gitster
authored andcommitted
t4048: abstract away SHA-1-specific constants
Adjust the test so that it computes variables for object IDs instead of using hard-coded hashes. Signed-off-by: brian m. carlson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent cf02be8 commit fa26d5e

File tree

1 file changed

+32
-26
lines changed

1 file changed

+32
-26
lines changed

t/t4048-diff-combined-binary.sh

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,48 +9,51 @@ test_expect_success 'setup binary merge conflict' '
99
git commit -m one &&
1010
echo twoQ2 | q_to_nul >binary &&
1111
git commit -a -m two &&
12+
two=$(git rev-parse --short HEAD:binary) &&
1213
git checkout -b branch-binary HEAD^ &&
1314
echo threeQ3 | q_to_nul >binary &&
1415
git commit -a -m three &&
16+
three=$(git rev-parse --short HEAD:binary) &&
1517
test_must_fail git merge master &&
1618
echo resolvedQhooray | q_to_nul >binary &&
17-
git commit -a -m resolved
19+
git commit -a -m resolved &&
20+
res=$(git rev-parse --short HEAD:binary)
1821
'
1922

20-
cat >expect <<'EOF'
23+
cat >expect <<EOF
2124
resolved
2225
2326
diff --git a/binary b/binary
24-
index 7ea6ded..9563691 100644
27+
index $three..$res 100644
2528
Binary files a/binary and b/binary differ
2629
resolved
2730
2831
diff --git a/binary b/binary
29-
index 6197570..9563691 100644
32+
index $two..$res 100644
3033
Binary files a/binary and b/binary differ
3134
EOF
3235
test_expect_success 'diff -m indicates binary-ness' '
3336
git show --format=%s -m >actual &&
3437
test_cmp expect actual
3538
'
3639

37-
cat >expect <<'EOF'
40+
cat >expect <<EOF
3841
resolved
3942
4043
diff --combined binary
41-
index 7ea6ded,6197570..9563691
44+
index $three,$two..$res
4245
Binary files differ
4346
EOF
4447
test_expect_success 'diff -c indicates binary-ness' '
4548
git show --format=%s -c >actual &&
4649
test_cmp expect actual
4750
'
4851

49-
cat >expect <<'EOF'
52+
cat >expect <<EOF
5053
resolved
5154
5255
diff --cc binary
53-
index 7ea6ded,6197570..9563691
56+
index $three,$two..$res
5457
Binary files differ
5558
EOF
5659
test_expect_success 'diff --cc indicates binary-ness' '
@@ -62,47 +65,50 @@ test_expect_success 'setup non-binary with binary attribute' '
6265
git checkout master &&
6366
test_commit one text &&
6467
test_commit two text &&
68+
two=$(git rev-parse --short HEAD:text) &&
6569
git checkout -b branch-text HEAD^ &&
6670
test_commit three text &&
71+
three=$(git rev-parse --short HEAD:text) &&
6772
test_must_fail git merge master &&
6873
test_commit resolved text &&
74+
res=$(git rev-parse --short HEAD:text) &&
6975
echo text -diff >.gitattributes
7076
'
7177

72-
cat >expect <<'EOF'
78+
cat >expect <<EOF
7379
resolved
7480
7581
diff --git a/text b/text
76-
index 2bdf67a..2ab19ae 100644
82+
index $three..$res 100644
7783
Binary files a/text and b/text differ
7884
resolved
7985
8086
diff --git a/text b/text
81-
index f719efd..2ab19ae 100644
87+
index $two..$res 100644
8288
Binary files a/text and b/text differ
8389
EOF
8490
test_expect_success 'diff -m respects binary attribute' '
8591
git show --format=%s -m >actual &&
8692
test_cmp expect actual
8793
'
8894

89-
cat >expect <<'EOF'
95+
cat >expect <<EOF
9096
resolved
9197
9298
diff --combined text
93-
index 2bdf67a,f719efd..2ab19ae
99+
index $three,$two..$res
94100
Binary files differ
95101
EOF
96102
test_expect_success 'diff -c respects binary attribute' '
97103
git show --format=%s -c >actual &&
98104
test_cmp expect actual
99105
'
100106

101-
cat >expect <<'EOF'
107+
cat >expect <<EOF
102108
resolved
103109
104110
diff --cc text
105-
index 2bdf67a,f719efd..2ab19ae
111+
index $three,$two..$res
106112
Binary files differ
107113
EOF
108114
test_expect_success 'diff --cc respects binary attribute' '
@@ -115,11 +121,11 @@ test_expect_success 'setup textconv attribute' '
115121
git config diff.upcase.textconv "tr a-z A-Z <"
116122
'
117123

118-
cat >expect <<'EOF'
124+
cat >expect <<EOF
119125
resolved
120126
121127
diff --git a/text b/text
122-
index 2bdf67a..2ab19ae 100644
128+
index $three..$res 100644
123129
--- a/text
124130
+++ b/text
125131
@@ -1 +1 @@
@@ -128,7 +134,7 @@ index 2bdf67a..2ab19ae 100644
128134
resolved
129135
130136
diff --git a/text b/text
131-
index f719efd..2ab19ae 100644
137+
index $two..$res 100644
132138
--- a/text
133139
+++ b/text
134140
@@ -1 +1 @@
@@ -140,11 +146,11 @@ test_expect_success 'diff -m respects textconv attribute' '
140146
test_cmp expect actual
141147
'
142148

143-
cat >expect <<'EOF'
149+
cat >expect <<EOF
144150
resolved
145151
146152
diff --combined text
147-
index 2bdf67a,f719efd..2ab19ae
153+
index $three,$two..$res
148154
--- a/text
149155
+++ b/text
150156
@@@ -1,1 -1,1 +1,1 @@@
@@ -157,11 +163,11 @@ test_expect_success 'diff -c respects textconv attribute' '
157163
test_cmp expect actual
158164
'
159165

160-
cat >expect <<'EOF'
166+
cat >expect <<EOF
161167
resolved
162168
163169
diff --cc text
164-
index 2bdf67a,f719efd..2ab19ae
170+
index $three,$two..$res
165171
--- a/text
166172
+++ b/text
167173
@@@ -1,1 -1,1 +1,1 @@@
@@ -174,9 +180,9 @@ test_expect_success 'diff --cc respects textconv attribute' '
174180
test_cmp expect actual
175181
'
176182

177-
cat >expect <<'EOF'
183+
cat >expect <<EOF
178184
diff --combined text
179-
index 2bdf67a,f719efd..2ab19ae
185+
index $three,$two..$res
180186
--- a/text
181187
+++ b/text
182188
@@@ -1,1 -1,1 +1,1 @@@
@@ -190,9 +196,9 @@ test_expect_success 'diff-tree plumbing does not respect textconv' '
190196
test_cmp expect actual
191197
'
192198

193-
cat >expect <<'EOF'
199+
cat >expect <<EOF
194200
diff --cc text
195-
index 2bdf67a,f719efd..0000000
201+
index $three,$two..0000000
196202
--- a/text
197203
+++ b/text
198204
@@@ -1,1 -1,1 +1,5 @@@

0 commit comments

Comments
 (0)