@@ -9,82 +9,82 @@ 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-
3129cat > expected << \EOF
3230:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 6ff87c4664981e4397625791c8ea3bbb5f2279a3 C100 path0/COPYING path1/COPYING
3331EOF
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+ '
37+
38+ test_expect_success ' copy detection, cached' '
39+ git diff-index -C --find-copies-harder --cached $tree >current &&
40+ compare_diff_raw current expected
41+ '
3842
3943# In the tree, there is only path0/COPYING. In the cache, path0 and
4044# path1 both have COPYING and the latter is a copy of path0/COPYING.
4145# However when we say we care only about path1, we should just see
4246# path1/COPYING suddenly appearing from nowhere, not detected as
4347# a copy from path0/COPYING.
4448
45- git diff-index -C $tree path1 > current
46-
4749cat > expected << \EOF
4850:000000 100644 0000000000000000000000000000000000000000 6ff87c4664981e4397625791c8ea3bbb5f2279a3 A path1/COPYING
4951EOF
5052
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'
53+ test_expect_success ' copy, limited to a subtree' '
54+ git diff-index -C --find-copies-harder $tree path1 >current &&
55+ compare_diff_raw current expected
56+ '
5957
58+ test_expect_success ' tweak work tree' '
59+ rm -f path0/COPYING &&
60+ git update-index --remove path0/COPYING
61+ '
6062# In the tree, there is only path0/COPYING. In the cache, path0 does
6163# not have COPYING anymore and path1 has COPYING which is a copy of
6264# path0/COPYING. Showing the full tree with cache should tell us about
6365# the rename.
6466
65- git diff-index -C $tree > current
66-
6767cat > expected << \EOF
6868:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 6ff87c4664981e4397625791c8ea3bbb5f2279a3 R100 path0/COPYING path1/COPYING
6969EOF
7070
71- test_expect_success \
72- ' validate the result (#3)' \
73- ' compare_diff_raw current expected'
71+ test_expect_success ' rename detection' '
72+ git diff-index -C --find-copies-harder $tree >current &&
73+ compare_diff_raw current expected
74+ '
7475
7576# In the tree, there is only path0/COPYING. In the cache, path0 does
7677# not have COPYING anymore and path1 has COPYING which is a copy of
7778# path0/COPYING. When we say we care only about path1, we should just
7879# see path1/COPYING appearing from nowhere.
7980
80- git diff-index -C $tree path1 > current
81-
8281cat > expected << \EOF
8382:000000 100644 0000000000000000000000000000000000000000 6ff87c4664981e4397625791c8ea3bbb5f2279a3 A path1/COPYING
8483EOF
8584
86- test_expect_success \
87- ' validate the result (#4)' \
88- ' compare_diff_raw current expected'
85+ test_expect_success ' rename, limited to a subtree' '
86+ git diff-index -C --find-copies-harder $tree path1 >current &&
87+ compare_diff_raw current expected
88+ '
8989
9090test_done
0 commit comments