Skip to content

Commit dbcf775

Browse files
committed
Merge branch 'sb/t4005-modernize' into maint
Test clean-up. * sb/t4005-modernize: t4005: modernize style and drop hard coded sha1
2 parents 33c3c2d + 68241cb commit dbcf775

File tree

1 file changed

+43
-52
lines changed

1 file changed

+43
-52
lines changed

t/t4005-diff-rename-2.sh

Lines changed: 43 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -3,84 +3,75 @@
33
# Copyright (c) 2005 Junio C Hamano
44
#
55

6-
test_description='Same rename detection as t4003 but testing diff-raw.
6+
test_description='Same rename detection as t4003 but testing diff-raw.'
77

8-
'
98
. ./test-lib.sh
109
. "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash
1110

12-
test_expect_success \
13-
'prepare reference tree' \
14-
'cat "$TEST_DIRECTORY"/diff-lib/COPYING >COPYING &&
15-
echo frotz >rezrov &&
16-
git update-index --add COPYING rezrov &&
17-
tree=$(git write-tree) &&
18-
echo $tree'
19-
20-
test_expect_success \
21-
'prepare work tree' \
22-
'sed -e 's/HOWEVER/However/' <COPYING >COPYING.1 &&
23-
sed -e 's/GPL/G.P.L/g' <COPYING >COPYING.2 &&
24-
rm -f COPYING &&
25-
git update-index --add --remove COPYING COPYING.?'
11+
test_expect_success 'setup reference tree' '
12+
cat "$TEST_DIRECTORY"/diff-lib/COPYING >COPYING &&
13+
echo frotz >rezrov &&
14+
git update-index --add COPYING rezrov &&
15+
tree=$(git write-tree) &&
16+
echo $tree &&
17+
sed -e 's/HOWEVER/However/' <COPYING >COPYING.1 &&
18+
sed -e 's/GPL/G.P.L/g' <COPYING >COPYING.2 &&
19+
origoid=$(git hash-object COPYING) &&
20+
oid1=$(git hash-object COPYING.1) &&
21+
oid2=$(git hash-object COPYING.2)
22+
'
2623

24+
################################################################
2725
# tree has COPYING and rezrov. work tree has COPYING.1 and COPYING.2,
2826
# both are slightly edited, and unchanged rezrov. We say COPYING.1
2927
# and COPYING.2 are based on COPYING, and do not say anything about
3028
# rezrov.
3129

32-
git diff-index -C $tree >current
33-
34-
cat >expected <<\EOF
35-
:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234 COPYING COPYING.1
36-
:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 06c67961bbaed34a127f76d261f4c0bf73eda471 R1234 COPYING COPYING.2
37-
EOF
30+
test_expect_success 'validate output from rename/copy detection (#1)' '
31+
rm -f COPYING &&
32+
git update-index --add --remove COPYING COPYING.? &&
3833
39-
test_expect_success \
40-
'validate output from rename/copy detection (#1)' \
41-
'compare_diff_raw current expected'
34+
cat <<-EOF >expected &&
35+
:100644 100644 $origoid $oid1 C1234 COPYING COPYING.1
36+
:100644 100644 $origoid $oid2 R1234 COPYING COPYING.2
37+
EOF
38+
git diff-index -C $tree >current &&
39+
compare_diff_raw expected current
40+
'
4241

4342
################################################################
44-
45-
test_expect_success \
46-
'prepare work tree again' \
47-
'mv COPYING.2 COPYING &&
48-
git update-index --add --remove COPYING COPYING.1 COPYING.2'
49-
5043
# tree has COPYING and rezrov. work tree has COPYING and COPYING.1,
5144
# both are slightly edited, and unchanged rezrov. We say COPYING.1
5245
# is based on COPYING and COPYING is still there, and do not say anything
5346
# about rezrov.
5447

55-
git diff-index -C $tree >current
56-
cat >expected <<\EOF
57-
:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 06c67961bbaed34a127f76d261f4c0bf73eda471 M COPYING
58-
:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234 COPYING COPYING.1
59-
EOF
48+
test_expect_success 'validate output from rename/copy detection (#2)' '
49+
mv COPYING.2 COPYING &&
50+
git update-index --add --remove COPYING COPYING.1 COPYING.2 &&
6051
61-
test_expect_success \
62-
'validate output from rename/copy detection (#2)' \
63-
'compare_diff_raw current expected'
52+
cat <<-EOF >expected &&
53+
:100644 100644 $origoid $oid2 M COPYING
54+
:100644 100644 $origoid $oid1 C1234 COPYING COPYING.1
55+
EOF
56+
git diff-index -C $tree >current &&
57+
compare_diff_raw current expected
58+
'
6459

6560
################################################################
66-
6761
# tree has COPYING and rezrov. work tree has the same COPYING and
6862
# copy-edited COPYING.1, and unchanged rezrov. We should not say
6963
# anything about rezrov or COPYING, since the revised again diff-raw
7064
# nows how to say Copy.
7165

72-
test_expect_success \
73-
'prepare work tree once again' \
74-
'cat "$TEST_DIRECTORY"/diff-lib/COPYING >COPYING &&
75-
git update-index --add --remove COPYING COPYING.1'
76-
77-
git diff-index -C --find-copies-harder $tree >current
78-
cat >expected <<\EOF
79-
:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234 COPYING COPYING.1
80-
EOF
66+
test_expect_success 'validate output from rename/copy detection (#3)' '
67+
cat "$TEST_DIRECTORY"/diff-lib/COPYING >COPYING &&
68+
git update-index --add --remove COPYING COPYING.1 &&
8169
82-
test_expect_success \
83-
'validate output from rename/copy detection (#3)' \
84-
'compare_diff_raw current expected'
70+
cat <<-EOF >expected &&
71+
:100644 100644 $origoid $oid1 C1234 COPYING COPYING.1
72+
EOF
73+
git diff-index -C --find-copies-harder $tree >current &&
74+
compare_diff_raw current expected
75+
'
8576

8677
test_done

0 commit comments

Comments
 (0)