]> git.ipfire.org Git - thirdparty/git.git/blame - t/t4005-diff-rename-2.sh
[PATCH] Make -C less eager.
[thirdparty/git.git] / t / t4005-diff-rename-2.sh
CommitLineData
f7c1512a
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.
7
8'
9. ./test-lib.sh
edb0c724 10. ../diff-lib.sh ;# test-lib chdir's into trash
b6d8f309 11
f7c1512a
JH
12test_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'
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 &&
25 git-update-cache --add --remove COPYING COPYING.?'
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
32git-diff-cache -M $tree >current
33
34cat >expected <<\EOF
b6d8f309
JH
35:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234 COPYING COPYING.1
36:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 06c67961bbaed34a127f76d261f4c0bf73eda471 R1234 COPYING COPYING.2
f7c1512a
JH
37EOF
38
39test_expect_success \
b6d8f309
JH
40 'validate output from rename/copy detection (#1)' \
41 'compare_diff_raw current expected'
42
43# make sure diff-helper can grok it.
44mv expected diff-raw
45GIT_DIFF_OPTS=--unified=0 git-diff-helper <diff-raw >current
46cat >expected <<\EOF
47diff --git a/COPYING b/COPYING.1
48copy from COPYING
49copy 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
55diff --git a/COPYING b/COPYING.2
dc938417
LT
56rename from COPYING
57rename to COPYING.2
b6d8f309
JH
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
69EOF
70
71test_expect_success \
72 'validate output from diff-helper (#1)' \
73 'compare_diff_patch current expected'
74
75################################################################
f7c1512a
JH
76
77test_expect_success \
78 'prepare work tree again' \
79 'mv COPYING.2 COPYING &&
80 git-update-cache --add --remove COPYING COPYING.1 COPYING.2'
81
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.
86
87git-diff-cache -C $tree >current
88cat >expected <<\EOF
b6d8f309 89:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 06c67961bbaed34a127f76d261f4c0bf73eda471 M COPYING
25d5ea41 90:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234 COPYING COPYING.1
f7c1512a
JH
91EOF
92
93test_expect_success \
b6d8f309
JH
94 'validate output from rename/copy detection (#2)' \
95 'compare_diff_raw current expected'
f7c1512a 96
b6d8f309
JH
97# make sure diff-helper can grok it.
98mv expected diff-raw
99GIT_DIFF_OPTS=--unified=0 git-diff-helper <diff-raw >current
100cat >expected <<\EOF
b6d8f309
JH
101diff --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
25d5ea41
JH
113diff --git a/COPYING b/COPYING.1
114copy from COPYING
115copy 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
b6d8f309
JH
121EOF
122
123test_expect_success \
124 'validate output from diff-helper (#2)' \
125 'compare_diff_patch current expected'
126
127################################################################
128
f7c1512a 129# tree has COPYING and rezrov. work tree has the same COPYING and
bceafe75
JH
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.
f7c1512a 133
ddafa7e9
JH
134test_expect_success \
135 'prepare work tree once again' \
136 'cat ../../COPYING >COPYING &&
137 git-update-cache --add --remove COPYING COPYING.1'
138
4727f640 139git-diff-cache -C --find-copies-harder $tree >current
f7c1512a 140cat >expected <<\EOF
b6d8f309 141:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234 COPYING COPYING.1
b6d8f309
JH
142EOF
143
144test_expect_success \
145 'validate output from rename/copy detection (#3)' \
146 'compare_diff_raw current expected'
147
148# make sure diff-helper can grok it.
149mv expected diff-raw
150GIT_DIFF_OPTS=--unified=0 git-diff-helper <diff-raw >current
151cat >expected <<\EOF
152diff --git a/COPYING b/COPYING.1
153copy from COPYING
154copy 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
f7c1512a
JH
160EOF
161
162test_expect_success \
b6d8f309
JH
163 'validate output from diff-helper (#3)' \
164 'compare_diff_patch current expected'
f7c1512a
JH
165
166test_done