Merge branch 'master' of https://github.com/Softcatala/git-po
[git/debian.git] / t / t4005-diff-rename-2.sh
blobf542d2929d2316fa8d858fc29c1bdfb5ef4c3c71
1 #!/bin/sh
3 # Copyright (c) 2005 Junio C Hamano
6 test_description='Same rename detection as t4003 but testing diff-raw.'
8 . ./test-lib.sh
9 . "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash
11 test_expect_success 'setup reference tree' '
12 cat "$TEST_DIRECTORY"/diff-lib/COPYING >COPYING &&
13 echo frotz >rezrov &&
14 git update-index --add COPYING rezrov &&
15 tree=$(git write-tree) &&
16 echo $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
28 # rezrov.
30 test_expect_success 'validate output from rename/copy detection (#1)' '
31 rm -f COPYING &&
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
37 EOF
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
46 # about rezrov.
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
55 EOF
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"/diff-lib/COPYING >COPYING &&
68 git update-index --add --remove COPYING COPYING.1 &&
70 cat <<-EOF >expected &&
71 :100644 100644 $origoid $oid1 C1234 COPYING COPYING.1
72 EOF
73 git diff-index -C --find-copies-harder $tree >current &&
74 compare_diff_raw current expected
77 test_done