]> git.ipfire.org Git - thirdparty/git.git/blame - t/t4007-rename-3.sh
Merge branch 'wb/fsmonitor-bitmap-fix'
[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'
9. ./test-lib.sh
bfdbee98 10. "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash
15d061b4 11
aceae2ef
JH
12test_expect_success 'prepare reference tree' '
13 mkdir path0 path1 &&
459b8d22 14 cp "$TEST_DIRECTORY"/diff-lib/COPYING path0/COPYING &&
aceae2ef
JH
15 git update-index --add path0/COPYING &&
16 tree=$(git write-tree) &&
17 echo $tree
18'
19
31fb3f42 20blob=$(git hash-object "$TEST_DIRECTORY/diff-lib/COPYING")
aceae2ef
JH
21test_expect_success 'prepare work tree' '
22 cp path0/COPYING path1/COPYING &&
23 git update-index --add --remove path0/COPYING path1/COPYING
24'
15d061b4
JH
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
31fb3f42 30cat >expected <<EOF
31:100644 100644 $blob $blob C100 path0/COPYING path1/COPYING
15d061b4
JH
32EOF
33
aceae2ef
JH
34test_expect_success 'copy detection' '
35 git diff-index -C --find-copies-harder $tree >current &&
36 compare_diff_raw current expected
37'
15d061b4 38
a0919ced
JH
39test_expect_success 'copy detection, cached' '
40 git diff-index -C --find-copies-harder --cached $tree >current &&
41 compare_diff_raw current expected
42'
43
15d061b4
JH
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.
6145ee8b
JH
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.
15d061b4 49
31fb3f42 50cat >expected <<EOF
51:000000 100644 $ZERO_OID $blob A path1/COPYING
15d061b4
JH
52EOF
53
aceae2ef
JH
54test_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'
15d061b4 58
aceae2ef
JH
59test_expect_success 'tweak work tree' '
60 rm -f path0/COPYING &&
61 git update-index --remove path0/COPYING
62'
15d061b4
JH
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
31fb3f42 68cat >expected <<EOF
69:100644 100644 $blob $blob R100 path0/COPYING path1/COPYING
15d061b4
JH
70EOF
71
aceae2ef
JH
72test_expect_success 'rename detection' '
73 git diff-index -C --find-copies-harder $tree >current &&
74 compare_diff_raw current expected
75'
15d061b4
JH
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
6145ee8b
JH
79# path0/COPYING. When we say we care only about path1, we should just
80# see path1/COPYING appearing from nowhere.
15d061b4 81
31fb3f42 82cat >expected <<EOF
83:000000 100644 $ZERO_OID $blob A path1/COPYING
15d061b4
JH
84EOF
85
aceae2ef
JH
86test_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'
15d061b4
JH
90
91test_done