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 <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
brian m. carlson committed
Oct 28, 2019 at 00:59 UTC
fa26d5ede6e6c2a07590d3564efc1f92f82fcc0f
1 file changed
+32
-26
t/t4048-diff-combined-binary.sh
+32
-26
@@ -9,24 +9,27 @@ test_expect_success 'setup binary merge conflict' '
9
git commit -m one &&
10
echo twoQ2 | q_to_nul >binary &&
11
git commit -a -m two &&
12
+ two=$(git rev-parse --short HEAD:binary) &&
13
git checkout -b branch-binary HEAD^ &&
14
echo threeQ3 | q_to_nul >binary &&
15
git commit -a -m three &&
16
+ three=$(git rev-parse --short HEAD:binary) &&
17
test_must_fail git merge master &&
18
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)
21
'
22
20
-cat >expect <<'EOF'
23
+cat >expect <<EOF
24
resolved
25
26
diff --git a/binary b/binary
24
-index 7ea6ded..9563691 100644
27
+index $three..$res 100644
28
Binary files a/binary and b/binary differ
29
resolved
30
31
diff --git a/binary b/binary
29
-index 6197570..9563691 100644
32
+index $two..$res 100644
33
Binary files a/binary and b/binary differ
34
EOF
35
test_expect_success 'diff -m indicates binary-ness' '
@@ -34,11 +37,11 @@ test_expect_success 'diff -m indicates binary-ness' '
37
test_cmp expect actual
38
'
39
37
-cat >expect <<'EOF'
40
+cat >expect <<EOF
41
resolved
42
43
diff --combined binary
41
-index 7ea6ded,6197570..9563691
44
+index $three,$two..$res
45
Binary files differ
46
EOF
47
test_expect_success 'diff -c indicates binary-ness' '
@@ -46,11 +49,11 @@ test_expect_success 'diff -c indicates binary-ness' '
49
test_cmp expect actual
50
'
51
49
-cat >expect <<'EOF'
52
+cat >expect <<EOF
53
resolved
54
55
diff --cc binary
53
-index 7ea6ded,6197570..9563691
56
+index $three,$two..$res
57
Binary files differ
58
EOF
59
test_expect_success 'diff --cc indicates binary-ness' '
@@ -62,23 +65,26 @@ test_expect_success 'setup non-binary with binary attribute' '
65
git checkout master &&
66
test_commit one text &&
67
test_commit two text &&
68
+ two=$(git rev-parse --short HEAD:text) &&
69
git checkout -b branch-text HEAD^ &&
70
test_commit three text &&
71
+ three=$(git rev-parse --short HEAD:text) &&
72
test_must_fail git merge master &&
73
test_commit resolved text &&
74
+ res=$(git rev-parse --short HEAD:text) &&
75
echo text -diff >.gitattributes
76
'
77
72
-cat >expect <<'EOF'
78
+cat >expect <<EOF
79
resolved
80
81
diff --git a/text b/text
76
-index 2bdf67a..2ab19ae 100644
82
+index $three..$res 100644
83
Binary files a/text and b/text differ
84
resolved
85
86
diff --git a/text b/text
81
-index f719efd..2ab19ae 100644
87
+index $two..$res 100644
88
Binary files a/text and b/text differ
89
EOF
90
test_expect_success 'diff -m respects binary attribute' '
@@ -86,11 +92,11 @@ test_expect_success 'diff -m respects binary attribute' '
92
test_cmp expect actual
93
'
94
89
-cat >expect <<'EOF'
95
+cat >expect <<EOF
96
resolved
97
98
diff --combined text
93
-index 2bdf67a,f719efd..2ab19ae
99
+index $three,$two..$res
100
Binary files differ
101
EOF
102
test_expect_success 'diff -c respects binary attribute' '
@@ -98,11 +104,11 @@ test_expect_success 'diff -c respects binary attribute' '
104
test_cmp expect actual
105
'
106
101
-cat >expect <<'EOF'
107
+cat >expect <<EOF
108
resolved
109
110
diff --cc text
105
-index 2bdf67a,f719efd..2ab19ae
111
+index $three,$two..$res
112
Binary files differ
113
EOF
114
test_expect_success 'diff --cc respects binary attribute' '
@@ -115,11 +121,11 @@ test_expect_success 'setup textconv attribute' '
121
git config diff.upcase.textconv "tr a-z A-Z <"
122
'
123
118
-cat >expect <<'EOF'
124
+cat >expect <<EOF
125
resolved
126
127
diff --git a/text b/text
122
-index 2bdf67a..2ab19ae 100644
128
+index $three..$res 100644
129
--- a/text
130
+++ b/text
131
@@ -1 +1 @@
@@ -128,7 +134,7 @@ index 2bdf67a..2ab19ae 100644
134
resolved
135
136
diff --git a/text b/text
131
-index f719efd..2ab19ae 100644
137
+index $two..$res 100644
138
--- a/text
139
+++ b/text
140
@@ -1 +1 @@
@@ -140,11 +146,11 @@ test_expect_success 'diff -m respects textconv attribute' '
146
test_cmp expect actual
147
'
148
143
-cat >expect <<'EOF'
149
+cat >expect <<EOF
150
resolved
151
152
diff --combined text
147
-index 2bdf67a,f719efd..2ab19ae
153
+index $three,$two..$res
154
--- a/text
155
+++ b/text
156
@@@ -1,1 -1,1 +1,1 @@@
@@ -157,11 +163,11 @@ test_expect_success 'diff -c respects textconv attribute' '
163
test_cmp expect actual
164
'
165
160
-cat >expect <<'EOF'
166
+cat >expect <<EOF
167
resolved
168
169
diff --cc text
164
-index 2bdf67a,f719efd..2ab19ae
170
+index $three,$two..$res
171
--- a/text
172
+++ b/text
173
@@@ -1,1 -1,1 +1,1 @@@
@@ -174,9 +180,9 @@ test_expect_success 'diff --cc respects textconv attribute' '
180
test_cmp expect actual
181
'
182
177
-cat >expect <<'EOF'
183
+cat >expect <<EOF
184
diff --combined text
179
-index 2bdf67a,f719efd..2ab19ae
185
+index $three,$two..$res
186
--- a/text
187
+++ b/text
188
@@@ -1,1 -1,1 +1,1 @@@
@@ -190,9 +196,9 @@ test_expect_success 'diff-tree plumbing does not respect textconv' '
196
test_cmp expect actual
197
'
198
193
-cat >expect <<'EOF'
199
+cat >expect <<EOF
200
diff --cc text
195
-index 2bdf67a,f719efd..0000000
201
+index $three,$two..0000000
202
--- a/text
203
+++ b/text
204
@@@ -1,1 -1,1 +1,5 @@@