bisect: peel annotated tags to commits
[git] / t / t4009-diff-rename-4.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2005 Junio C Hamano
4 #
5
6 test_description='Same rename detection as t4003 but testing diff-raw -z.
7
8 '
9 . ./test-lib.sh
10 . "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash
11
12 test_expect_success \
13     'prepare reference tree' \
14     'cat "$TEST_DIRECTORY"/diff-lib/COPYING >COPYING &&
15      echo frotz >rezrov &&
16     git update-index --add COPYING rezrov &&
17     orig=$(git hash-object COPYING) &&
18     tree=$(git write-tree) &&
19     echo $tree'
20
21 test_expect_success \
22     'prepare work tree' \
23     'sed -e 's/HOWEVER/However/' <COPYING >COPYING.1 &&
24     sed -e 's/GPL/G.P.L/g' <COPYING >COPYING.2 &&
25     rm -f COPYING &&
26     c1=$(git hash-object COPYING.1) &&
27     c2=$(git hash-object COPYING.2) &&
28     git update-index --add --remove COPYING COPYING.?'
29
30 # tree has COPYING and rezrov.  work tree has COPYING.1 and COPYING.2,
31 # both are slightly edited, and unchanged rezrov.  We say COPYING.1
32 # and COPYING.2 are based on COPYING, and do not say anything about
33 # rezrov.
34
35 git diff-index -z -C $tree >current
36
37 cat >expected <<EOF
38 :100644 100644 $orig $c1 C1234
39 COPYING
40 COPYING.1
41 :100644 100644 $orig $c2 R1234
42 COPYING
43 COPYING.2
44 EOF
45
46 test_expect_success \
47     'validate output from rename/copy detection (#1)' \
48     'compare_diff_raw_z current expected'
49
50 ################################################################
51
52 test_expect_success \
53     'prepare work tree again' \
54     'mv COPYING.2 COPYING &&
55      git update-index --add --remove COPYING COPYING.1 COPYING.2'
56
57 # tree has COPYING and rezrov.  work tree has COPYING and COPYING.1,
58 # both are slightly edited, and unchanged rezrov.  We say COPYING.1
59 # is based on COPYING and COPYING is still there, and do not say anything
60 # about rezrov.
61
62 git diff-index -z -C $tree >current
63 cat >expected <<EOF
64 :100644 100644 $orig $c2 M
65 COPYING
66 :100644 100644 $orig $c1 C1234
67 COPYING
68 COPYING.1
69 EOF
70
71 test_expect_success \
72     'validate output from rename/copy detection (#2)' \
73     'compare_diff_raw_z current expected'
74
75 ################################################################
76
77 # tree has COPYING and rezrov.  work tree has the same COPYING and
78 # copy-edited COPYING.1, and unchanged rezrov.  We should not say
79 # anything about rezrov or COPYING, since the revised again diff-raw
80 # nows how to say Copy.
81
82 test_expect_success \
83     'prepare work tree once again' \
84     'cat "$TEST_DIRECTORY"/diff-lib/COPYING >COPYING &&
85      git update-index --add --remove COPYING COPYING.1'
86
87 git diff-index -z -C --find-copies-harder $tree >current
88 cat >expected <<EOF
89 :100644 100644 $orig $c1 C1234
90 COPYING
91 COPYING.1
92 EOF
93
94 test_expect_success \
95     'validate output from rename/copy detection (#3)' \
96     'compare_diff_raw_z current expected'
97
98 test_done