Merge branch 'jc/ci-upload-artifact-and-linux32'
[git/gitster.git] / t / t4005-diff-rename-2.sh
blob5c756dc24358cfe28219d2097b96f3655a9e13f0
1 #!/bin/sh
3 # Copyright (c) 2005 Junio C Hamano
6 test_description='Same rename detection as t4003 but testing diff-raw.'
9 TEST_PASSES_SANITIZE_LEAK=true
10 . ./test-lib.sh
11 . "$TEST_DIRECTORY"/lib-diff.sh ;# test-lib chdir's into trash
13 test_expect_success 'setup reference tree' '
14 COPYING_test_data >COPYING &&
15 echo frotz >rezrov &&
16 git update-index --add COPYING rezrov &&
17 tree=$(git write-tree) &&
18 echo $tree &&
19 sed -e "s/HOWEVER/However/" <COPYING >COPYING.1 &&
20 sed -e "s/GPL/G.P.L/g" <COPYING >COPYING.2 &&
21 origoid=$(git hash-object COPYING) &&
22 oid1=$(git hash-object COPYING.1) &&
23 oid2=$(git hash-object COPYING.2)
26 ################################################################
27 # tree has COPYING and rezrov. work tree has COPYING.1 and COPYING.2,
28 # both are slightly edited, and unchanged rezrov. We say COPYING.1
29 # and COPYING.2 are based on COPYING, and do not say anything about
30 # rezrov.
32 test_expect_success 'validate output from rename/copy detection (#1)' '
33 rm -f COPYING &&
34 git update-index --add --remove COPYING COPYING.? &&
36 cat <<-EOF >expected &&
37 :100644 100644 $origoid $oid1 C1234 COPYING COPYING.1
38 :100644 100644 $origoid $oid2 R1234 COPYING COPYING.2
39 EOF
40 git diff-index -C $tree >current &&
41 compare_diff_raw expected current
44 ################################################################
45 # tree has COPYING and rezrov. work tree has COPYING and COPYING.1,
46 # both are slightly edited, and unchanged rezrov. We say COPYING.1
47 # is based on COPYING and COPYING is still there, and do not say anything
48 # about rezrov.
50 test_expect_success 'validate output from rename/copy detection (#2)' '
51 mv COPYING.2 COPYING &&
52 git update-index --add --remove COPYING COPYING.1 COPYING.2 &&
54 cat <<-EOF >expected &&
55 :100644 100644 $origoid $oid2 M COPYING
56 :100644 100644 $origoid $oid1 C1234 COPYING COPYING.1
57 EOF
58 git diff-index -C $tree >current &&
59 compare_diff_raw current expected
62 ################################################################
63 # tree has COPYING and rezrov. work tree has the same COPYING and
64 # copy-edited COPYING.1, and unchanged rezrov. We should not say
65 # anything about rezrov or COPYING, since the revised again diff-raw
66 # nows how to say Copy.
68 test_expect_success 'validate output from rename/copy detection (#3)' '
69 COPYING_test_data >COPYING &&
70 git update-index --add --remove COPYING COPYING.1 &&
72 cat <<-EOF >expected &&
73 :100644 100644 $origoid $oid1 C1234 COPYING COPYING.1
74 EOF
75 git diff-index -C --find-copies-harder $tree >current &&
76 compare_diff_raw current expected
79 test_done