]> git.ipfire.org Git - thirdparty/git.git/blame - t/t4009-diff-rename-4.sh
Big tool rename.
[thirdparty/git.git] / t / t4009-diff-rename-4.sh
CommitLineData
ddafa7e9
JH
1#!/bin/sh
2#
3# Copyright (c) 2005 Junio C Hamano
4#
5
6test_description='Same rename detection as t4003 but testing diff-raw -z.
7
8'
9. ./test-lib.sh
edb0c724 10. ../diff-lib.sh ;# test-lib chdir's into trash
ddafa7e9
JH
11
12test_expect_success \
13 'prepare reference tree' \
14 'cat ../../COPYING >COPYING &&
15 echo frotz >rezrov &&
215a7ad1 16 git-update-index --add COPYING rezrov &&
ddafa7e9
JH
17 tree=$(git-write-tree) &&
18 echo $tree'
19
20test_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 &&
215a7ad1 25 git-update-index --add --remove COPYING COPYING.?'
ddafa7e9
JH
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.
31
215a7ad1 32git-diff-index -z -M $tree >current
ddafa7e9
JH
33
34cat >expected <<\EOF
35:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234
36COPYING
37COPYING.1
38:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 06c67961bbaed34a127f76d261f4c0bf73eda471 R1234
39COPYING
40COPYING.2
41EOF
42
43test_expect_success \
44 'validate output from rename/copy detection (#1)' \
edb0c724 45 'compare_diff_raw_z current expected'
ddafa7e9
JH
46
47# make sure diff-helper can grok it.
48mv current diff-raw
49GIT_DIFF_OPTS=--unified=0 git-diff-helper -z <diff-raw >current
50cat >expected <<\EOF
51diff --git a/COPYING b/COPYING.1
52copy from COPYING
53copy to COPYING.1
54--- a/COPYING
55+++ b/COPYING.1
56@@ -6 +6 @@
57- HOWEVER, in order to allow a migration to GPLv3 if that seems like
58+ However, in order to allow a migration to GPLv3 if that seems like
59diff --git a/COPYING b/COPYING.2
dc938417
LT
60rename from COPYING
61rename to COPYING.2
ddafa7e9
JH
62--- a/COPYING
63+++ b/COPYING.2
64@@ -2 +2 @@
65- Note that the only valid version of the GPL as far as this project
66+ Note that the only valid version of the G.P.L as far as this project
67@@ -6 +6 @@
68- HOWEVER, in order to allow a migration to GPLv3 if that seems like
69+ HOWEVER, in order to allow a migration to G.P.Lv3 if that seems like
70@@ -12 +12 @@
71- This file is licensed under the GPL v2, or a later version
72+ This file is licensed under the G.P.L v2, or a later version
73EOF
74
75test_expect_success \
76 'validate output from diff-helper (#1)' \
77 'compare_diff_patch current expected'
78
79################################################################
80
81test_expect_success \
82 'prepare work tree again' \
83 'mv COPYING.2 COPYING &&
215a7ad1 84 git-update-index --add --remove COPYING COPYING.1 COPYING.2'
ddafa7e9
JH
85
86# tree has COPYING and rezrov. work tree has COPYING and COPYING.1,
87# both are slightly edited, and unchanged rezrov. We say COPYING.1
88# is based on COPYING and COPYING is still there, and do not say anything
89# about rezrov.
90
215a7ad1 91git-diff-index -z -C $tree >current
ddafa7e9
JH
92cat >expected <<\EOF
93:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 06c67961bbaed34a127f76d261f4c0bf73eda471 M
94COPYING
95:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234
96COPYING
97COPYING.1
98EOF
99
100test_expect_success \
101 'validate output from rename/copy detection (#2)' \
edb0c724 102 'compare_diff_raw_z current expected'
ddafa7e9
JH
103
104# make sure diff-helper can grok it.
105mv current diff-raw
106GIT_DIFF_OPTS=--unified=0 git-diff-helper -z <diff-raw >current
107cat >expected <<\EOF
108diff --git a/COPYING b/COPYING
109--- a/COPYING
110+++ b/COPYING
111@@ -2 +2 @@
112- Note that the only valid version of the GPL as far as this project
113+ Note that the only valid version of the G.P.L as far as this project
114@@ -6 +6 @@
115- HOWEVER, in order to allow a migration to GPLv3 if that seems like
116+ HOWEVER, in order to allow a migration to G.P.Lv3 if that seems like
117@@ -12 +12 @@
118- This file is licensed under the GPL v2, or a later version
119+ This file is licensed under the G.P.L v2, or a later version
120diff --git a/COPYING b/COPYING.1
121copy from COPYING
122copy to COPYING.1
123--- a/COPYING
124+++ b/COPYING.1
125@@ -6 +6 @@
126- HOWEVER, in order to allow a migration to GPLv3 if that seems like
127+ However, in order to allow a migration to GPLv3 if that seems like
128EOF
129
130test_expect_success \
131 'validate output from diff-helper (#2)' \
132 'compare_diff_patch current expected'
133
134################################################################
135
136# tree has COPYING and rezrov. work tree has the same COPYING and
137# copy-edited COPYING.1, and unchanged rezrov. We should not say
138# anything about rezrov nor COPYING, since the revised again diff-raw
139# nows how to say Copy.
140
141test_expect_success \
142 'prepare work tree once again' \
143 'cat ../../COPYING >COPYING &&
215a7ad1 144 git-update-index --add --remove COPYING COPYING.1'
ddafa7e9 145
215a7ad1 146git-diff-index -z -C --find-copies-harder $tree >current
ddafa7e9
JH
147cat >expected <<\EOF
148:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234
149COPYING
150COPYING.1
151EOF
152
153test_expect_success \
154 'validate output from rename/copy detection (#3)' \
edb0c724 155 'compare_diff_raw_z current expected'
ddafa7e9
JH
156
157# make sure diff-helper can grok it.
158mv current diff-raw
159GIT_DIFF_OPTS=--unified=0 git-diff-helper -z <diff-raw >current
160cat >expected <<\EOF
161diff --git a/COPYING b/COPYING.1
162copy from COPYING
163copy to COPYING.1
164--- a/COPYING
165+++ b/COPYING.1
166@@ -6 +6 @@
167- HOWEVER, in order to allow a migration to GPLv3 if that seems like
168+ However, in order to allow a migration to GPLv3 if that seems like
169EOF
170
171test_expect_success \
172 'validate output from diff-helper (#3)' \
173 'compare_diff_patch current expected'
174
175test_done