Skip to content

Commit 70ec6bd

Browse files
rscharfegitster
authored andcommitted
t1002: stop using sum(1)
sum(1) is a command for calculating checksums of the contents of files. It was part of early editions of Unix ("Research Unix", 1972/1973, [1]). cksum(1) appeared in 4.4BSD (1993) as a replacement [2], and became part of POSIX.1-2008 [3]. OpenBSD 5.6 (2014) removed sum(1). We only use sum(1) in t1002 to check for changes in three files. On MinGW we use md5sum(1) instead. We could switch to the standard command cksum(1) for all platforms; MinGW comes with GNU coreutils now, which provides sum(1), cksum(1) and md5sum(1). Use our standard method for checking for file changes instead: test_cmp. It's more convenient because it shows differences nicely, it's faster on MinGW because we have a special implementation there based only on shell-internal commands, it's simpler as it allows us to avoid stripping out unnecessary entries from the checksum file using grep(1), and it's more consistent with the rest of the test suite. We already compare changed files with their expected new contents using diff(1), so we don't need to check with "test_must_fail test_cmp" if they differ from their original state. A later patch could convert the direct diff(1) calls to test_cmp as well. With all sum(1) calls gone, remove the MinGW-specific implementation from test-lib.sh as well. [1] http://minnie.tuhs.org/cgi-bin/utree.pl?file=V3/man/man1/sum.1 [2] http://minnie.tuhs.org/cgi-bin/utree.pl?file=4.4BSD/usr/share/man/cat1/cksum.0 [3] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/cksum.html Signed-off-by: René Scharfe <[email protected]> Reviewed-by: Johannes Sixt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0bfff81 commit 70ec6bd

File tree

2 files changed

+35
-35
lines changed

2 files changed

+35
-35
lines changed

t/t1002-read-tree-m-u-2way.sh

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ test_expect_success \
5151
treeM=$(git write-tree) &&
5252
echo treeM $treeM &&
5353
git ls-tree $treeM &&
54-
sum bozbar frotz nitfol >M.sum &&
54+
cp bozbar bozbar.M &&
55+
cp frotz frotz.M &&
56+
cp nitfol nitfol.M &&
5557
git diff-tree $treeH $treeM'
5658

5759
test_expect_success \
@@ -61,8 +63,9 @@ test_expect_success \
6163
read_tree_u_must_succeed -m -u $treeH $treeM &&
6264
git ls-files --stage >1-3.out &&
6365
cmp M.out 1-3.out &&
64-
sum bozbar frotz nitfol >actual3.sum &&
65-
cmp M.sum actual3.sum &&
66+
test_cmp bozbar.M bozbar &&
67+
test_cmp frotz.M frotz &&
68+
test_cmp nitfol.M nitfol &&
6669
check_cache_at bozbar clean &&
6770
check_cache_at frotz clean &&
6871
check_cache_at nitfol clean'
@@ -79,8 +82,9 @@ test_expect_success \
7982
test_might_fail git diff -U0 --no-index M.out 4.out >4diff.out &&
8083
compare_change 4diff.out expected &&
8184
check_cache_at yomin clean &&
82-
sum bozbar frotz nitfol >actual4.sum &&
83-
cmp M.sum actual4.sum &&
85+
test_cmp bozbar.M bozbar &&
86+
test_cmp frotz.M frotz &&
87+
test_cmp nitfol.M nitfol &&
8488
echo yomin >yomin1 &&
8589
diff yomin yomin1 &&
8690
rm -f yomin1'
@@ -98,8 +102,9 @@ test_expect_success \
98102
test_might_fail git diff -U0 --no-index M.out 5.out >5diff.out &&
99103
compare_change 5diff.out expected &&
100104
check_cache_at yomin dirty &&
101-
sum bozbar frotz nitfol >actual5.sum &&
102-
cmp M.sum actual5.sum &&
105+
test_cmp bozbar.M bozbar &&
106+
test_cmp frotz.M frotz &&
107+
test_cmp nitfol.M nitfol &&
103108
: dirty index should have prevented -u from checking it out. &&
104109
echo yomin yomin >yomin1 &&
105110
diff yomin yomin1 &&
@@ -115,8 +120,9 @@ test_expect_success \
115120
git ls-files --stage >6.out &&
116121
test_cmp M.out 6.out &&
117122
check_cache_at frotz clean &&
118-
sum bozbar frotz nitfol >actual3.sum &&
119-
cmp M.sum actual3.sum &&
123+
test_cmp bozbar.M bozbar &&
124+
test_cmp frotz.M frotz &&
125+
test_cmp nitfol.M nitfol &&
120126
echo frotz >frotz1 &&
121127
diff frotz frotz1 &&
122128
rm -f frotz1'
@@ -132,8 +138,8 @@ test_expect_success \
132138
git ls-files --stage >7.out &&
133139
test_cmp M.out 7.out &&
134140
check_cache_at frotz dirty &&
135-
sum bozbar frotz nitfol >actual7.sum &&
136-
if cmp M.sum actual7.sum; then false; else :; fi &&
141+
test_cmp bozbar.M bozbar &&
142+
test_cmp nitfol.M nitfol &&
137143
: dirty index should have prevented -u from checking it out. &&
138144
echo frotz frotz >frotz1 &&
139145
diff frotz frotz1 &&
@@ -165,8 +171,10 @@ test_expect_success \
165171
read_tree_u_must_succeed -m -u $treeH $treeM &&
166172
git ls-files --stage >10.out &&
167173
cmp M.out 10.out &&
168-
sum bozbar frotz nitfol >actual10.sum &&
169-
cmp M.sum actual10.sum'
174+
test_cmp bozbar.M bozbar &&
175+
test_cmp frotz.M frotz &&
176+
test_cmp nitfol.M nitfol
177+
'
170178

171179
test_expect_success \
172180
'11 - dirty path removed.' \
@@ -209,11 +217,8 @@ test_expect_success \
209217
git ls-files --stage >14.out &&
210218
test_must_fail git diff -U0 --no-index M.out 14.out >14diff.out &&
211219
compare_change 14diff.out expected &&
212-
sum bozbar frotz >actual14.sum &&
213-
grep -v nitfol M.sum > expected14.sum &&
214-
cmp expected14.sum actual14.sum &&
215-
sum bozbar frotz nitfol >actual14a.sum &&
216-
if cmp M.sum actual14a.sum; then false; else :; fi &&
220+
test_cmp bozbar.M bozbar &&
221+
test_cmp frotz.M frotz &&
217222
check_cache_at nitfol clean &&
218223
echo nitfol nitfol >nitfol1 &&
219224
diff nitfol nitfol1 &&
@@ -231,11 +236,8 @@ test_expect_success \
231236
test_must_fail git diff -U0 --no-index M.out 15.out >15diff.out &&
232237
compare_change 15diff.out expected &&
233238
check_cache_at nitfol dirty &&
234-
sum bozbar frotz >actual15.sum &&
235-
grep -v nitfol M.sum > expected15.sum &&
236-
cmp expected15.sum actual15.sum &&
237-
sum bozbar frotz nitfol >actual15a.sum &&
238-
if cmp M.sum actual15a.sum; then false; else :; fi &&
239+
test_cmp bozbar.M bozbar &&
240+
test_cmp frotz.M frotz &&
239241
echo nitfol nitfol nitfol >nitfol1 &&
240242
diff nitfol nitfol1 &&
241243
rm -f nitfol1'
@@ -267,8 +269,10 @@ test_expect_success \
267269
git ls-files --stage >18.out &&
268270
test_cmp M.out 18.out &&
269271
check_cache_at bozbar clean &&
270-
sum bozbar frotz nitfol >actual18.sum &&
271-
cmp M.sum actual18.sum'
272+
test_cmp bozbar.M bozbar &&
273+
test_cmp frotz.M frotz &&
274+
test_cmp nitfol.M nitfol
275+
'
272276

273277
test_expect_success \
274278
'19 - local change already having a good result, further modified.' \
@@ -281,11 +285,8 @@ test_expect_success \
281285
git ls-files --stage >19.out &&
282286
test_cmp M.out 19.out &&
283287
check_cache_at bozbar dirty &&
284-
sum frotz nitfol >actual19.sum &&
285-
grep -v bozbar M.sum > expected19.sum &&
286-
cmp expected19.sum actual19.sum &&
287-
sum bozbar frotz nitfol >actual19a.sum &&
288-
if cmp M.sum actual19a.sum; then false; else :; fi &&
288+
test_cmp frotz.M frotz &&
289+
test_cmp nitfol.M nitfol &&
289290
echo gnusto gnusto >bozbar1 &&
290291
diff bozbar bozbar1 &&
291292
rm -f bozbar1'
@@ -300,8 +301,10 @@ test_expect_success \
300301
git ls-files --stage >20.out &&
301302
test_cmp M.out 20.out &&
302303
check_cache_at bozbar clean &&
303-
sum bozbar frotz nitfol >actual20.sum &&
304-
cmp M.sum actual20.sum'
304+
test_cmp bozbar.M bozbar &&
305+
test_cmp frotz.M frotz &&
306+
test_cmp nitfol.M nitfol
307+
'
305308

306309
test_expect_success \
307310
'21 - no local change, dirty cache.' \

t/test-lib.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -975,9 +975,6 @@ case $(uname -s) in
975975
find () {
976976
/usr/bin/find "$@"
977977
}
978-
sum () {
979-
md5sum "$@"
980-
}
981978
# git sees Windows-style pwd
982979
pwd () {
983980
builtin pwd -W

0 commit comments

Comments
 (0)