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>
Junio C Hamano committed
May 22, 2009 at 23:06 UTC
aceae2ef9261718324bf1853401d5ee9686a54a8
1 file changed
+32
-37
t/t4007-rename-3.sh
+32
-37
@@ -9,32 +9,31 @@ test_description='Rename interaction with pathspec.
9
. ./test-lib.sh
10
. "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash
11
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
+'
24
25
# In the tree, there is only path0/COPYING. In the cache, path0 and
26
# path1 both have COPYING and the latter is a copy of path0/COPYING.
27
# Comparing the full tree with cache should tell us so.
28
29
-git diff-index -C --find-copies-harder $tree >current
30
-
29
cat >expected <<\EOF
30
:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 6ff87c4664981e4397625791c8ea3bbb5f2279a3 C100 path0/COPYING path1/COPYING
31
EOF
32
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
+'
37
38
# In the tree, there is only path0/COPYING. In the cache, path0 and
39
# path1 both have COPYING and the latter is a copy of path0/COPYING.
@@ -42,49 +41,45 @@ test_expect_success \
41
# path1/COPYING suddenly appearing from nowhere, not detected as
42
# a copy from path0/COPYING.
43
45
-git diff-index -C $tree path1 >current
46
-
44
cat >expected <<\EOF
45
:000000 100644 0000000000000000000000000000000000000000 6ff87c4664981e4397625791c8ea3bbb5f2279a3 A path1/COPYING
46
EOF
47
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
+'
52
53
+test_expect_success 'tweak work tree' '
54
+ rm -f path0/COPYING &&
55
+ git update-index --remove path0/COPYING
56
+'
57
# In the tree, there is only path0/COPYING. In the cache, path0 does
58
# not have COPYING anymore and path1 has COPYING which is a copy of
59
# path0/COPYING. Showing the full tree with cache should tell us about
60
# the rename.
61
65
-git diff-index -C $tree >current
66
-
62
cat >expected <<\EOF
63
:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 6ff87c4664981e4397625791c8ea3bbb5f2279a3 R100 path0/COPYING path1/COPYING
64
EOF
65
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
+'
70
71
# In the tree, there is only path0/COPYING. In the cache, path0 does
72
# not have COPYING anymore and path1 has COPYING which is a copy of
73
# path0/COPYING. When we say we care only about path1, we should just
74
# see path1/COPYING appearing from nowhere.
75
80
-git diff-index -C $tree path1 >current
81
-
76
cat >expected <<\EOF
77
:000000 100644 0000000000000000000000000000000000000000 6ff87c4664981e4397625791c8ea3bbb5f2279a3 A path1/COPYING
78
EOF
79
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
+'
84
85
test_done