Merge branch 'l10n/zh_TW/220113' of github.com:l10n-tw/git-po
[alt-git.git] / t / t4007-rename-3.sh
blobb86165cbac5970fda7b169f80edea8deea5ccf12
1 #!/bin/sh
3 # Copyright (c) 2005 Junio C Hamano
6 test_description='Rename interaction with pathspec.
10 TEST_PASSES_SANITIZE_LEAK=true
11 . ./test-lib.sh
12 . "$TEST_DIRECTORY"/lib-diff.sh ;# test-lib chdir's into trash
14 test_expect_success 'prepare reference tree' '
15 mkdir path0 path1 &&
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.
31 cat >expected <<EOF
32 :100644 100644 $blob $blob C100 path0/COPYING path1/COPYING
33 EOF
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.
51 cat >expected <<EOF
52 :000000 100644 $ZERO_OID $blob A path1/COPYING
53 EOF
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
67 # the rename.
69 cat >expected <<EOF
70 :100644 100644 $blob $blob R100 path0/COPYING path1/COPYING
71 EOF
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.
83 cat >expected <<EOF
84 :000000 100644 $ZERO_OID $blob A path1/COPYING
85 EOF
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
92 test_done