3 # Copyright (c) 2005 Junio C Hamano
6 test_description='Same rename detection as t4003 but testing diff-raw.'
9 . "$TEST_DIRECTORY"/lib-diff.sh ;# test-lib chdir's into trash
11 test_expect_success 'setup reference tree' '
12 cat "$TEST_DIRECTORY"/lib-diff/COPYING >COPYING &&
14 git update-index --add COPYING rezrov &&
15 tree=$(git write-tree) &&
17 sed -e "s/HOWEVER/However/" <COPYING >COPYING.1 &&
18 sed -e "s/GPL/G.P.L/g" <COPYING >COPYING.2 &&
19 origoid=$(git hash-object COPYING) &&
20 oid1=$(git hash-object COPYING.1) &&
21 oid2=$(git hash-object COPYING.2)
24 ################################################################
25 # tree has COPYING and rezrov. work tree has COPYING.1 and COPYING.2,
26 # both are slightly edited, and unchanged rezrov. We say COPYING.1
27 # and COPYING.2 are based on COPYING, and do not say anything about
30 test_expect_success 'validate output from rename/copy detection (#1)' '
32 git update-index --add --remove COPYING COPYING.? &&
34 cat <<-EOF >expected &&
35 :100644 100644 $origoid $oid1 C1234 COPYING COPYING.1
36 :100644 100644 $origoid $oid2 R1234 COPYING COPYING.2
38 git diff-index -C $tree >current &&
39 compare_diff_raw expected current
42 ################################################################
43 # tree has COPYING and rezrov. work tree has COPYING and COPYING.1,
44 # both are slightly edited, and unchanged rezrov. We say COPYING.1
45 # is based on COPYING and COPYING is still there, and do not say anything
48 test_expect_success 'validate output from rename/copy detection (#2)' '
49 mv COPYING.2 COPYING &&
50 git update-index --add --remove COPYING COPYING.1 COPYING.2 &&
52 cat <<-EOF >expected &&
53 :100644 100644 $origoid $oid2 M COPYING
54 :100644 100644 $origoid $oid1 C1234 COPYING COPYING.1
56 git diff-index -C $tree >current &&
57 compare_diff_raw current expected
60 ################################################################
61 # tree has COPYING and rezrov. work tree has the same COPYING and
62 # copy-edited COPYING.1, and unchanged rezrov. We should not say
63 # anything about rezrov or COPYING, since the revised again diff-raw
64 # nows how to say Copy.
66 test_expect_success 'validate output from rename/copy detection (#3)' '
67 cat "$TEST_DIRECTORY"/lib-diff/COPYING >COPYING &&
68 git update-index --add --remove COPYING COPYING.1 &&
70 cat <<-EOF >expected &&
71 :100644 100644 $origoid $oid1 C1234 COPYING COPYING.1
73 git diff-index -C --find-copies-harder $tree >current &&
74 compare_diff_raw current expected