]> git.ipfire.org Git - thirdparty/git.git/blob - t/t4007-rename-3.sh
path.c: don't call the match function without value in trie_find()
[thirdparty/git.git] / t / t4007-rename-3.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2005 Junio C Hamano
4 #
5
6 test_description='Rename interaction with pathspec.
7
8 '
9 . ./test-lib.sh
10 . "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash
11
12 test_expect_success 'prepare reference tree' '
13 mkdir path0 path1 &&
14 cp "$TEST_DIRECTORY"/diff-lib/COPYING path0/COPYING &&
15 git update-index --add path0/COPYING &&
16 tree=$(git write-tree) &&
17 echo $tree
18 '
19
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
24 '
25
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.
29
30 cat >expected <<EOF
31 :100644 100644 $blob $blob C100 path0/COPYING path1/COPYING
32 EOF
33
34 test_expect_success 'copy detection' '
35 git diff-index -C --find-copies-harder $tree >current &&
36 compare_diff_raw current expected
37 '
38
39 test_expect_success 'copy detection, cached' '
40 git diff-index -C --find-copies-harder --cached $tree >current &&
41 compare_diff_raw current expected
42 '
43
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.
49
50 cat >expected <<EOF
51 :000000 100644 $ZERO_OID $blob A path1/COPYING
52 EOF
53
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
57 '
58
59 test_expect_success 'tweak work tree' '
60 rm -f path0/COPYING &&
61 git update-index --remove path0/COPYING
62 '
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
66 # the rename.
67
68 cat >expected <<EOF
69 :100644 100644 $blob $blob R100 path0/COPYING path1/COPYING
70 EOF
71
72 test_expect_success 'rename detection' '
73 git diff-index -C --find-copies-harder $tree >current &&
74 compare_diff_raw current expected
75 '
76
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.
81
82 cat >expected <<EOF
83 :000000 100644 $ZERO_OID $blob A path1/COPYING
84 EOF
85
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
89 '
90
91 test_done