Skip to content

Commit aceae2e

Browse files
committed
t4007: modernize the style
This is one of the oldest scripts; update it to match more modern style. Notably, we should: - Put the test title on the same line as the "test_expect_success", and end the line with a single-quote to begin the body of the test which is one multi-line string; and - Run as many commands inside test_expect_success, not outside, to catch unexpected breakages. Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent b87fc96 commit aceae2e

1 file changed

Lines changed: 32 additions & 37 deletions

File tree

t/t4007-rename-3.sh

Lines changed: 32 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,82 +9,77 @@ test_description='Rename interaction with pathspec.
99
. ./test-lib.sh
1010
. "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash
1111

12-
test_expect_success \
13-
'prepare reference tree' \
14-
'mkdir path0 path1 &&
15-
cp "$TEST_DIRECTORY"/../COPYING path0/COPYING &&
16-
git update-index --add path0/COPYING &&
17-
tree=$(git write-tree) &&
18-
echo $tree'
19-
20-
test_expect_success \
21-
'prepare work tree' \
22-
'cp path0/COPYING path1/COPYING &&
23-
git update-index --add --remove path0/COPYING path1/COPYING'
12+
test_expect_success 'prepare reference tree' '
13+
mkdir path0 path1 &&
14+
cp "$TEST_DIRECTORY"/../COPYING path0/COPYING &&
15+
git update-index --add path0/COPYING &&
16+
tree=$(git write-tree) &&
17+
echo $tree
18+
'
19+
20+
test_expect_success 'prepare work tree' '
21+
cp path0/COPYING path1/COPYING &&
22+
git update-index --add --remove path0/COPYING path1/COPYING
23+
'
2424

2525
# In the tree, there is only path0/COPYING. In the cache, path0 and
2626
# path1 both have COPYING and the latter is a copy of path0/COPYING.
2727
# Comparing the full tree with cache should tell us so.
2828

29-
git diff-index -C --find-copies-harder $tree >current
30-
3129
cat >expected <<\EOF
3230
:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 6ff87c4664981e4397625791c8ea3bbb5f2279a3 C100 path0/COPYING path1/COPYING
3331
EOF
3432

35-
test_expect_success \
36-
'validate the result (#1)' \
37-
'compare_diff_raw current expected'
33+
test_expect_success 'copy detection' '
34+
git diff-index -C --find-copies-harder $tree >current &&
35+
compare_diff_raw current expected
36+
'
3837

3938
# In the tree, there is only path0/COPYING. In the cache, path0 and
4039
# path1 both have COPYING and the latter is a copy of path0/COPYING.
4140
# However when we say we care only about path1, we should just see
4241
# path1/COPYING suddenly appearing from nowhere, not detected as
4342
# a copy from path0/COPYING.
4443

45-
git diff-index -C $tree path1 >current
46-
4744
cat >expected <<\EOF
4845
:000000 100644 0000000000000000000000000000000000000000 6ff87c4664981e4397625791c8ea3bbb5f2279a3 A path1/COPYING
4946
EOF
5047

51-
test_expect_success \
52-
'validate the result (#2)' \
53-
'compare_diff_raw current expected'
54-
55-
test_expect_success \
56-
'tweak work tree' \
57-
'rm -f path0/COPYING &&
58-
git update-index --remove path0/COPYING'
48+
test_expect_success 'copy, limited to a subtree' '
49+
git diff-index -C --find-copies-harder $tree path1 >current &&
50+
compare_diff_raw current expected
51+
'
5952

53+
test_expect_success 'tweak work tree' '
54+
rm -f path0/COPYING &&
55+
git update-index --remove path0/COPYING
56+
'
6057
# In the tree, there is only path0/COPYING. In the cache, path0 does
6158
# not have COPYING anymore and path1 has COPYING which is a copy of
6259
# path0/COPYING. Showing the full tree with cache should tell us about
6360
# the rename.
6461

65-
git diff-index -C $tree >current
66-
6762
cat >expected <<\EOF
6863
:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 6ff87c4664981e4397625791c8ea3bbb5f2279a3 R100 path0/COPYING path1/COPYING
6964
EOF
7065

71-
test_expect_success \
72-
'validate the result (#3)' \
73-
'compare_diff_raw current expected'
66+
test_expect_success 'rename detection' '
67+
git diff-index -C --find-copies-harder $tree >current &&
68+
compare_diff_raw current expected
69+
'
7470

7571
# In the tree, there is only path0/COPYING. In the cache, path0 does
7672
# not have COPYING anymore and path1 has COPYING which is a copy of
7773
# path0/COPYING. When we say we care only about path1, we should just
7874
# see path1/COPYING appearing from nowhere.
7975

80-
git diff-index -C $tree path1 >current
81-
8276
cat >expected <<\EOF
8377
:000000 100644 0000000000000000000000000000000000000000 6ff87c4664981e4397625791c8ea3bbb5f2279a3 A path1/COPYING
8478
EOF
8579

86-
test_expect_success \
87-
'validate the result (#4)' \
88-
'compare_diff_raw current expected'
80+
test_expect_success 'rename, limited to a subtree' '
81+
git diff-index -C --find-copies-harder $tree path1 >current &&
82+
compare_diff_raw current expected
83+
'
8984

9085
test_done

0 commit comments

Comments
 (0)