3 # Copyright (c) 2005 Junio C Hamano
6 test_description
='Rename interaction with pathspec.
10 TEST_PASSES_SANITIZE_LEAK
=true
12 .
"$TEST_DIRECTORY"/lib-diff.sh
;# test-lib chdir's into trash
14 test_expect_success
'prepare reference tree' '
16 COPYING_test_data >path0/COPYING &&
17 git update-index --add path0/COPYING &&
18 tree=$(git write-tree) &&
19 blob=$(git rev-parse :path0/COPYING)
22 test_expect_success
'prepare work tree' '
23 cp path0/COPYING path1/COPYING &&
24 git update-index --add --remove path0/COPYING path1/COPYING
27 # In the tree, there is only path0/COPYING. In the cache, path0 and
28 # path1 both have COPYING and the latter is a copy of path0/COPYING.
29 # Comparing the full tree with cache should tell us so.
32 :100644 100644 $blob $blob C100 path0/COPYING path1/COPYING
35 test_expect_success
'copy detection' '
36 git diff-index -C --find-copies-harder $tree >current &&
37 compare_diff_raw current expected
40 test_expect_success
'copy detection, cached' '
41 git diff-index -C --find-copies-harder --cached $tree >current &&
42 compare_diff_raw current expected
45 # In the tree, there is only path0/COPYING. In the cache, path0 and
46 # path1 both have COPYING and the latter is a copy of path0/COPYING.
47 # However when we say we care only about path1, we should just see
48 # path1/COPYING suddenly appearing from nowhere, not detected as
49 # a copy from path0/COPYING.
52 :000000 100644 $ZERO_OID $blob A path1/COPYING
55 test_expect_success
'copy, limited to a subtree' '
56 git diff-index -C --find-copies-harder $tree path1 >current &&
57 compare_diff_raw current expected
60 test_expect_success
'tweak work tree' '
61 rm -f path0/COPYING &&
62 git update-index --remove path0/COPYING
64 # In the tree, there is only path0/COPYING. In the cache, path0 does
65 # not have COPYING anymore and path1 has COPYING which is a copy of
66 # path0/COPYING. Showing the full tree with cache should tell us about
70 :100644 100644 $blob $blob R100 path0/COPYING path1/COPYING
73 test_expect_success
'rename detection' '
74 git diff-index -C --find-copies-harder $tree >current &&
75 compare_diff_raw current expected
78 # In the tree, there is only path0/COPYING. In the cache, path0 does
79 # not have COPYING anymore and path1 has COPYING which is a copy of
80 # path0/COPYING. When we say we care only about path1, we should just
81 # see path1/COPYING appearing from nowhere.
84 :000000 100644 $ZERO_OID $blob A path1/COPYING
87 test_expect_success
'rename, limited to a subtree' '
88 git diff-index -C --find-copies-harder $tree path1 >current &&
89 compare_diff_raw current expected