Merge branch 'jc/fsck'
[git/gitweb-caching.git] / t / t4003-diff-rename-1.sh
blob27519704d46d95deddbe8af75f985ede16bb4aaf
1 #!/bin/sh
3 # Copyright (c) 2005 Junio C Hamano
6 test_description='More rename detection
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-index --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-index --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. So we say you
29 # copy-and-edit one, and rename-and-edit the other. We do not say
30 # anything about rezrov.
32 GIT_DIFF_OPTS=--unified=0 git-diff-index -M -p $tree >current
33 cat >expected <<\EOF
34 diff --git a/COPYING b/COPYING.1
35 copy from COPYING
36 copy to COPYING.1
37 --- a/COPYING
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
42 diff --git a/COPYING b/COPYING.2
43 rename from COPYING
44 rename to COPYING.2
45 --- a/COPYING
46 +++ b/COPYING.2
47 @@ -2 +2 @@
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
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
56 EOF
58 test_expect_success \
59 'validate output from rename/copy detection (#1)' \
60 'compare_diff_patch current expected'
62 test_expect_success \
63 'prepare work tree again' \
64 'mv COPYING.2 COPYING &&
65 git-update-index --add --remove COPYING COPYING.1 COPYING.2'
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.
72 GIT_DIFF_OPTS=--unified=0 git-diff-index -C -p $tree >current
73 cat >expected <<\EOF
74 diff --git a/COPYING b/COPYING
75 --- a/COPYING
76 +++ b/COPYING
77 @@ -2 +2 @@
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
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
86 diff --git a/COPYING b/COPYING.1
87 copy from COPYING
88 copy 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
94 EOF
96 test_expect_success \
97 'validate output from rename/copy detection (#2)' \
98 'compare_diff_patch current expected'
100 test_expect_success \
101 'prepare work tree once again' \
102 'cat ../../COPYING >COPYING &&
103 git-update-index --add --remove COPYING COPYING.1'
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
109 # git-diff-index as well, should not be mentioned.
111 GIT_DIFF_OPTS=--unified=0 \
112 git-diff-index -C --find-copies-harder -p $tree >current
113 cat >expected <<\EOF
114 diff --git a/COPYING b/COPYING.1
115 copy from COPYING
116 copy to COPYING.1
117 --- a/COPYING
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
124 test_expect_success \
125 'validate output from rename/copy detection (#3)' \
126 'compare_diff_patch current expected'
128 test_done