]> git.ipfire.org Git - thirdparty/git.git/blame - t/t4007-rename-3.sh
The third batch
[thirdparty/git.git] / t / t4007-rename-3.sh
CommitLineData
15d061b4
JH
1#!/bin/sh
2#
3# Copyright (c) 2005 Junio C Hamano
4#
5
6test_description='Rename interaction with pathspec.
7
8'
d96fb140
ÆAB
9
10TEST_PASSES_SANITIZE_LEAK=true
15d061b4 11. ./test-lib.sh
ebd73f50 12. "$TEST_DIRECTORY"/lib-diff.sh ;# test-lib chdir's into trash
15d061b4 13
aceae2ef
JH
14test_expect_success 'prepare reference tree' '
15 mkdir path0 path1 &&
15b808da 16 COPYING_test_data >path0/COPYING &&
aceae2ef
JH
17 git update-index --add path0/COPYING &&
18 tree=$(git write-tree) &&
15b808da 19 blob=$(git rev-parse :path0/COPYING)
aceae2ef
JH
20'
21
22test_expect_success 'prepare work tree' '
23 cp path0/COPYING path1/COPYING &&
24 git update-index --add --remove path0/COPYING path1/COPYING
25'
15d061b4
JH
26
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.
30
31fb3f42 31cat >expected <<EOF
32:100644 100644 $blob $blob C100 path0/COPYING path1/COPYING
15d061b4
JH
33EOF
34
aceae2ef
JH
35test_expect_success 'copy detection' '
36 git diff-index -C --find-copies-harder $tree >current &&
37 compare_diff_raw current expected
38'
15d061b4 39
a0919ced
JH
40test_expect_success 'copy detection, cached' '
41 git diff-index -C --find-copies-harder --cached $tree >current &&
42 compare_diff_raw current expected
43'
44
15d061b4
JH
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.
6145ee8b
JH
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.
15d061b4 50
31fb3f42 51cat >expected <<EOF
52:000000 100644 $ZERO_OID $blob A path1/COPYING
15d061b4
JH
53EOF
54
aceae2ef
JH
55test_expect_success 'copy, limited to a subtree' '
56 git diff-index -C --find-copies-harder $tree path1 >current &&
57 compare_diff_raw current expected
58'
15d061b4 59
aceae2ef
JH
60test_expect_success 'tweak work tree' '
61 rm -f path0/COPYING &&
62 git update-index --remove path0/COPYING
63'
15d061b4
JH
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.
68
31fb3f42 69cat >expected <<EOF
70:100644 100644 $blob $blob R100 path0/COPYING path1/COPYING
15d061b4
JH
71EOF
72
aceae2ef
JH
73test_expect_success 'rename detection' '
74 git diff-index -C --find-copies-harder $tree >current &&
75 compare_diff_raw current expected
76'
15d061b4
JH
77
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
6145ee8b
JH
80# path0/COPYING. When we say we care only about path1, we should just
81# see path1/COPYING appearing from nowhere.
15d061b4 82
31fb3f42 83cat >expected <<EOF
84:000000 100644 $ZERO_OID $blob A path1/COPYING
15d061b4
JH
85EOF
86
aceae2ef
JH
87test_expect_success 'rename, limited to a subtree' '
88 git diff-index -C --find-copies-harder $tree path1 >current &&
89 compare_diff_raw current expected
90'
15d061b4
JH
91
92test_done