3 # Copyright (c) 2005 Junio C Hamano
6 test_description
='Rename interaction with pathspec.
10 .
"$TEST_DIRECTORY"/diff-lib.sh
;# test-lib chdir's into trash
12 test_expect_success
'prepare reference tree' '
14 cp "$TEST_DIRECTORY"/diff-lib/COPYING path0/COPYING &&
15 git update-index --add path0/COPYING &&
16 tree=$(git write-tree) &&
20 blob
=$
(git hash-object
"$TEST_DIRECTORY/diff-lib/COPYING")
21 test_expect_success
'prepare work tree' '
22 cp path0/COPYING path1/COPYING &&
23 git update-index --add --remove path0/COPYING path1/COPYING
26 # In the tree, there is only path0/COPYING. In the cache, path0 and
27 # path1 both have COPYING and the latter is a copy of path0/COPYING.
28 # Comparing the full tree with cache should tell us so.
31 :100644 100644 $blob $blob C100 path0/COPYING path1/COPYING
34 test_expect_success
'copy detection' '
35 git diff-index -C --find-copies-harder $tree >current &&
36 compare_diff_raw current expected
39 test_expect_success
'copy detection, cached' '
40 git diff-index -C --find-copies-harder --cached $tree >current &&
41 compare_diff_raw current expected
44 # In the tree, there is only path0/COPYING. In the cache, path0 and
45 # path1 both have COPYING and the latter is a copy of path0/COPYING.
46 # However when we say we care only about path1, we should just see
47 # path1/COPYING suddenly appearing from nowhere, not detected as
48 # a copy from path0/COPYING.
51 :000000 100644 $ZERO_OID $blob A path1/COPYING
54 test_expect_success
'copy, limited to a subtree' '
55 git diff-index -C --find-copies-harder $tree path1 >current &&
56 compare_diff_raw current expected
59 test_expect_success
'tweak work tree' '
60 rm -f path0/COPYING &&
61 git update-index --remove path0/COPYING
63 # In the tree, there is only path0/COPYING. In the cache, path0 does
64 # not have COPYING anymore and path1 has COPYING which is a copy of
65 # path0/COPYING. Showing the full tree with cache should tell us about
69 :100644 100644 $blob $blob R100 path0/COPYING path1/COPYING
72 test_expect_success
'rename detection' '
73 git diff-index -C --find-copies-harder $tree >current &&
74 compare_diff_raw current expected
77 # In the tree, there is only path0/COPYING. In the cache, path0 does
78 # not have COPYING anymore and path1 has COPYING which is a copy of
79 # path0/COPYING. When we say we care only about path1, we should just
80 # see path1/COPYING appearing from nowhere.
83 :000000 100644 $ZERO_OID $blob A path1/COPYING
86 test_expect_success
'rename, limited to a subtree' '
87 git diff-index -C --find-copies-harder $tree path1 >current &&
88 compare_diff_raw current expected