]> git.ipfire.org Git - thirdparty/git.git/blame - t/t4003-diff-rename-1.sh
The sixth batch
[thirdparty/git.git] / t / t4003-diff-rename-1.sh
CommitLineData
427dcb4b
JH
1#!/bin/sh
2#
3# Copyright (c) 2005 Junio C Hamano
4#
5
6test_description='More rename detection
7
8'
9. ./test-lib.sh
bfdbee98 10. "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash
b6d8f309 11
427dcb4b
JH
12test_expect_success \
13 'prepare reference tree' \
459b8d22 14 'cat "$TEST_DIRECTORY"/diff-lib/COPYING >COPYING &&
f7c1512a 15 echo frotz >rezrov &&
5be60078
JH
16 git update-index --add COPYING rezrov &&
17 tree=$(git write-tree) &&
427dcb4b
JH
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 &&
5be60078 25 git update-index --add --remove COPYING COPYING.?'
427dcb4b 26
f7c1512a
JH
27# tree has COPYING and rezrov. work tree has COPYING.1 and COPYING.2,
28# both are slightly edited, and unchanged rezrov. So we say you
29# copy-and-edit one, and rename-and-edit the other. We do not say
30# anything about rezrov.
c3e7fbcb 31
0940e5f2 32GIT_DIFF_OPTS=--unified=0 git diff-index -C -p $tree >current
427dcb4b 33cat >expected <<\EOF
b6d8f309 34diff --git a/COPYING b/COPYING.1
427dcb4b 35copy from COPYING
b6d8f309 36copy to COPYING.1
427dcb4b 37--- a/COPYING
b6d8f309
JH
38+++ b/COPYING.1
39@@ -6 +6 @@
40- HOWEVER, in order to allow a migration to GPLv3 if that seems like
41+ However, in order to allow a migration to GPLv3 if that seems like
42diff --git a/COPYING b/COPYING.2
dc938417
LT
43rename from COPYING
44rename to COPYING.2
427dcb4b 45--- a/COPYING
b6d8f309
JH
46+++ b/COPYING.2
47@@ -2 +2 @@
427dcb4b
JH
48- Note that the only valid version of the GPL as far as this project
49+ Note that the only valid version of the G.P.L as far as this project
b6d8f309
JH
50@@ -6 +6 @@
51- HOWEVER, in order to allow a migration to GPLv3 if that seems like
52+ HOWEVER, in order to allow a migration to G.P.Lv3 if that seems like
53@@ -12 +12 @@
54- This file is licensed under the GPL v2, or a later version
55+ This file is licensed under the G.P.L v2, or a later version
427dcb4b
JH
56EOF
57
58test_expect_success \
b6d8f309
JH
59 'validate output from rename/copy detection (#1)' \
60 'compare_diff_patch current expected'
427dcb4b
JH
61
62test_expect_success \
63 'prepare work tree again' \
64 'mv COPYING.2 COPYING &&
5be60078 65 git update-index --add --remove COPYING COPYING.1 COPYING.2'
c3e7fbcb 66
f7c1512a
JH
67# tree has COPYING and rezrov. work tree has COPYING and COPYING.1,
68# both are slightly edited, and unchanged rezrov. So we say you
69# edited one, and copy-and-edit the other. We do not say
70# anything about rezrov.
427dcb4b 71
5be60078 72GIT_DIFF_OPTS=--unified=0 git diff-index -C -p $tree >current
427dcb4b 73cat >expected <<\EOF
427dcb4b
JH
74diff --git a/COPYING b/COPYING
75--- a/COPYING
76+++ b/COPYING
b6d8f309 77@@ -2 +2 @@
427dcb4b
JH
78- Note that the only valid version of the GPL as far as this project
79+ Note that the only valid version of the G.P.L as far as this project
b6d8f309
JH
80@@ -6 +6 @@
81- HOWEVER, in order to allow a migration to GPLv3 if that seems like
82+ HOWEVER, in order to allow a migration to G.P.Lv3 if that seems like
83@@ -12 +12 @@
84- This file is licensed under the GPL v2, or a later version
85+ This file is licensed under the G.P.L v2, or a later version
25d5ea41
JH
86diff --git a/COPYING b/COPYING.1
87copy from COPYING
88copy to COPYING.1
89--- a/COPYING
90+++ b/COPYING.1
91@@ -6 +6 @@
92- HOWEVER, in order to allow a migration to GPLv3 if that seems like
93+ However, in order to allow a migration to GPLv3 if that seems like
427dcb4b
JH
94EOF
95
c3e7fbcb 96test_expect_success \
b6d8f309
JH
97 'validate output from rename/copy detection (#2)' \
98 'compare_diff_patch current expected'
c3e7fbcb
JH
99
100test_expect_success \
101 'prepare work tree once again' \
459b8d22 102 'cat "$TEST_DIRECTORY"/diff-lib/COPYING >COPYING &&
5be60078 103 git update-index --add --remove COPYING COPYING.1'
c3e7fbcb 104
f7c1512a
JH
105# tree has COPYING and rezrov. work tree has COPYING and COPYING.1,
106# but COPYING is not edited. We say you copy-and-edit COPYING.1; this
107# is only possible because -C mode now reports the unmodified file to
108# the diff-core. Unchanged rezrov, although being fed to
5be60078 109# git diff-index as well, should not be mentioned.
c3e7fbcb 110
4727f640 111GIT_DIFF_OPTS=--unified=0 \
5be60078 112 git diff-index -C --find-copies-harder -p $tree >current
c3e7fbcb 113cat >expected <<\EOF
b6d8f309 114diff --git a/COPYING b/COPYING.1
c3e7fbcb 115copy from COPYING
b6d8f309 116copy to COPYING.1
c3e7fbcb 117--- a/COPYING
b6d8f309
JH
118+++ b/COPYING.1
119@@ -6 +6 @@
120- HOWEVER, in order to allow a migration to GPLv3 if that seems like
121+ However, in order to allow a migration to GPLv3 if that seems like
c3e7fbcb
JH
122EOF
123
427dcb4b 124test_expect_success \
b6d8f309
JH
125 'validate output from rename/copy detection (#3)' \
126 'compare_diff_patch current expected'
427dcb4b
JH
127
128test_done