[PATCH] Dereference tag repeatedly until we get a non-tag.
[git/dkf.git] / t / t4005-diff-rename-2.sh
blobcee06e4c5dd2530c2147baa09434356b020b7933
1 #!/bin/sh
3 # Copyright (c) 2005 Junio C Hamano
6 test_description='Same rename detection as t4003 but testing diff-raw.
9 . ./test-lib.sh
10 . ../diff-lib.sh ;# test-lib chdir's into trash
12 test_expect_success \
13 'prepare reference tree' \
14 'cat ../../COPYING >COPYING &&
15 echo frotz >rezrov &&
16 git-update-cache --add COPYING rezrov &&
17 tree=$(git-write-tree) &&
18 echo $tree'
20 test_expect_success \
21 'prepare work tree' \
22 'sed -e 's/HOWEVER/However/' <COPYING >COPYING.1 &&
23 sed -e 's/GPL/G.P.L/g' <COPYING >COPYING.2 &&
24 rm -f COPYING &&
25 git-update-cache --add --remove COPYING COPYING.?'
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 git-diff-cache -M $tree >current
34 cat >expected <<\EOF
35 :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234 COPYING COPYING.1
36 :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 06c67961bbaed34a127f76d261f4c0bf73eda471 R1234 COPYING COPYING.2
37 EOF
39 test_expect_success \
40 'validate output from rename/copy detection (#1)' \
41 'compare_diff_raw current expected'
43 # make sure diff-helper can grok it.
44 mv expected diff-raw
45 GIT_DIFF_OPTS=--unified=0 git-diff-helper <diff-raw >current
46 cat >expected <<\EOF
47 diff --git a/COPYING b/COPYING.1
48 copy from COPYING
49 copy to COPYING.1
50 --- a/COPYING
51 +++ b/COPYING.1
52 @@ -6 +6 @@
53 - HOWEVER, in order to allow a migration to GPLv3 if that seems like
54 + However, in order to allow a migration to GPLv3 if that seems like
55 diff --git a/COPYING b/COPYING.2
56 rename from COPYING
57 rename to COPYING.2
58 --- a/COPYING
59 +++ b/COPYING.2
60 @@ -2 +2 @@
61 - Note that the only valid version of the GPL as far as this project
62 + Note that the only valid version of the G.P.L as far as this project
63 @@ -6 +6 @@
64 - HOWEVER, in order to allow a migration to GPLv3 if that seems like
65 + HOWEVER, in order to allow a migration to G.P.Lv3 if that seems like
66 @@ -12 +12 @@
67 - This file is licensed under the GPL v2, or a later version
68 + This file is licensed under the G.P.L v2, or a later version
69 EOF
71 test_expect_success \
72 'validate output from diff-helper (#1)' \
73 'compare_diff_patch current expected'
75 ################################################################
77 test_expect_success \
78 'prepare work tree again' \
79 'mv COPYING.2 COPYING &&
80 git-update-cache --add --remove COPYING COPYING.1 COPYING.2'
82 # tree has COPYING and rezrov. work tree has COPYING and COPYING.1,
83 # both are slightly edited, and unchanged rezrov. We say COPYING.1
84 # is based on COPYING and COPYING is still there, and do not say anything
85 # about rezrov.
87 git-diff-cache -C $tree >current
88 cat >expected <<\EOF
89 :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 06c67961bbaed34a127f76d261f4c0bf73eda471 M COPYING
90 :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234 COPYING COPYING.1
91 EOF
93 test_expect_success \
94 'validate output from rename/copy detection (#2)' \
95 'compare_diff_raw current expected'
97 # make sure diff-helper can grok it.
98 mv expected diff-raw
99 GIT_DIFF_OPTS=--unified=0 git-diff-helper <diff-raw >current
100 cat >expected <<\EOF
101 diff --git a/COPYING b/COPYING
102 --- a/COPYING
103 +++ b/COPYING
104 @@ -2 +2 @@
105 - Note that the only valid version of the GPL as far as this project
106 + Note that the only valid version of the G.P.L as far as this project
107 @@ -6 +6 @@
108 - HOWEVER, in order to allow a migration to GPLv3 if that seems like
109 + HOWEVER, in order to allow a migration to G.P.Lv3 if that seems like
110 @@ -12 +12 @@
111 - This file is licensed under the GPL v2, or a later version
112 + This file is licensed under the G.P.L v2, or a later version
113 diff --git a/COPYING b/COPYING.1
114 copy from COPYING
115 copy to COPYING.1
116 --- a/COPYING
117 +++ b/COPYING.1
118 @@ -6 +6 @@
119 - HOWEVER, in order to allow a migration to GPLv3 if that seems like
120 + However, in order to allow a migration to GPLv3 if that seems like
123 test_expect_success \
124 'validate output from diff-helper (#2)' \
125 'compare_diff_patch current expected'
127 ################################################################
129 # tree has COPYING and rezrov. work tree has the same COPYING and
130 # copy-edited COPYING.1, and unchanged rezrov. We should not say
131 # anything about rezrov nor COPYING, since the revised again diff-raw
132 # nows how to say Copy.
134 test_expect_success \
135 'prepare work tree once again' \
136 'cat ../../COPYING >COPYING &&
137 git-update-cache --add --remove COPYING COPYING.1'
139 git-diff-cache -C --find-copies-harder $tree >current
140 cat >expected <<\EOF
141 :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234 COPYING COPYING.1
144 test_expect_success \
145 'validate output from rename/copy detection (#3)' \
146 'compare_diff_raw current expected'
148 # make sure diff-helper can grok it.
149 mv expected diff-raw
150 GIT_DIFF_OPTS=--unified=0 git-diff-helper <diff-raw >current
151 cat >expected <<\EOF
152 diff --git a/COPYING b/COPYING.1
153 copy from COPYING
154 copy to COPYING.1
155 --- a/COPYING
156 +++ b/COPYING.1
157 @@ -6 +6 @@
158 - HOWEVER, in order to allow a migration to GPLv3 if that seems like
159 + However, in order to allow a migration to GPLv3 if that seems like
162 test_expect_success \
163 'validate output from diff-helper (#3)' \
164 'compare_diff_patch current expected'
166 test_done