]>
Commit | Line | Data |
---|---|---|
427dcb4b JH |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2005 Junio C Hamano | |
4 | # | |
5 | ||
6 | test_description='More rename detection | |
7 | ||
8 | ' | |
9 | . ./test-lib.sh | |
10 | ||
b6d8f309 JH |
11 | compare_diff_patch () { |
12 | # When heuristics are improved, the score numbers would change. | |
13 | # Ignore them while comparing. | |
14 | sed -e '/^similarity index [0-9]*%$/d' <"$1" >.tmp-1 | |
15 | sed -e '/^similarity index [0-9]*%$/d' <"$2" >.tmp-2 | |
16 | diff -u .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2 | |
17 | } | |
18 | ||
427dcb4b JH |
19 | test_expect_success \ |
20 | 'prepare reference tree' \ | |
21 | 'cat ../../COPYING >COPYING && | |
f7c1512a JH |
22 | echo frotz >rezrov && |
23 | git-update-cache --add COPYING rezrov && | |
427dcb4b JH |
24 | tree=$(git-write-tree) && |
25 | echo $tree' | |
26 | ||
27 | test_expect_success \ | |
28 | 'prepare work tree' \ | |
29 | 'sed -e 's/HOWEVER/However/' <COPYING >COPYING.1 && | |
30 | sed -e 's/GPL/G.P.L/g' <COPYING >COPYING.2 && | |
31 | rm -f COPYING && | |
32 | git-update-cache --add --remove COPYING COPYING.?' | |
33 | ||
f7c1512a JH |
34 | # tree has COPYING and rezrov. work tree has COPYING.1 and COPYING.2, |
35 | # both are slightly edited, and unchanged rezrov. So we say you | |
36 | # copy-and-edit one, and rename-and-edit the other. We do not say | |
37 | # anything about rezrov. | |
c3e7fbcb | 38 | |
b6d8f309 | 39 | GIT_DIFF_OPTS=--unified=0 git-diff-cache -M -p $tree >current |
427dcb4b | 40 | cat >expected <<\EOF |
b6d8f309 | 41 | diff --git a/COPYING b/COPYING.1 |
427dcb4b | 42 | copy from COPYING |
b6d8f309 | 43 | copy to COPYING.1 |
427dcb4b | 44 | --- a/COPYING |
b6d8f309 JH |
45 | +++ b/COPYING.1 |
46 | @@ -6 +6 @@ | |
47 | - HOWEVER, in order to allow a migration to GPLv3 if that seems like | |
48 | + However, in order to allow a migration to GPLv3 if that seems like | |
49 | diff --git a/COPYING b/COPYING.2 | |
427dcb4b | 50 | rename old COPYING |
b6d8f309 | 51 | rename new COPYING.2 |
427dcb4b | 52 | --- a/COPYING |
b6d8f309 JH |
53 | +++ b/COPYING.2 |
54 | @@ -2 +2 @@ | |
427dcb4b JH |
55 | - Note that the only valid version of the GPL as far as this project |
56 | + Note that the only valid version of the G.P.L as far as this project | |
b6d8f309 JH |
57 | @@ -6 +6 @@ |
58 | - HOWEVER, in order to allow a migration to GPLv3 if that seems like | |
59 | + HOWEVER, in order to allow a migration to G.P.Lv3 if that seems like | |
60 | @@ -12 +12 @@ | |
61 | - This file is licensed under the GPL v2, or a later version | |
62 | + This file is licensed under the G.P.L v2, or a later version | |
427dcb4b JH |
63 | EOF |
64 | ||
65 | test_expect_success \ | |
b6d8f309 JH |
66 | 'validate output from rename/copy detection (#1)' \ |
67 | 'compare_diff_patch current expected' | |
427dcb4b JH |
68 | |
69 | test_expect_success \ | |
70 | 'prepare work tree again' \ | |
71 | 'mv COPYING.2 COPYING && | |
c3e7fbcb JH |
72 | git-update-cache --add --remove COPYING COPYING.1 COPYING.2' |
73 | ||
f7c1512a JH |
74 | # tree has COPYING and rezrov. work tree has COPYING and COPYING.1, |
75 | # both are slightly edited, and unchanged rezrov. So we say you | |
76 | # edited one, and copy-and-edit the other. We do not say | |
77 | # anything about rezrov. | |
427dcb4b | 78 | |
b6d8f309 | 79 | GIT_DIFF_OPTS=--unified=0 git-diff-cache -C -p $tree >current |
427dcb4b | 80 | cat >expected <<\EOF |
427dcb4b JH |
81 | diff --git a/COPYING b/COPYING |
82 | --- a/COPYING | |
83 | +++ b/COPYING | |
b6d8f309 | 84 | @@ -2 +2 @@ |
427dcb4b JH |
85 | - Note that the only valid version of the GPL as far as this project |
86 | + Note that the only valid version of the G.P.L as far as this project | |
b6d8f309 JH |
87 | @@ -6 +6 @@ |
88 | - HOWEVER, in order to allow a migration to GPLv3 if that seems like | |
89 | + HOWEVER, in order to allow a migration to G.P.Lv3 if that seems like | |
90 | @@ -12 +12 @@ | |
91 | - This file is licensed under the GPL v2, or a later version | |
92 | + This file is licensed under the G.P.L v2, or a later version | |
25d5ea41 JH |
93 | diff --git a/COPYING b/COPYING.1 |
94 | copy from COPYING | |
95 | copy to COPYING.1 | |
96 | --- a/COPYING | |
97 | +++ b/COPYING.1 | |
98 | @@ -6 +6 @@ | |
99 | - HOWEVER, in order to allow a migration to GPLv3 if that seems like | |
100 | + However, in order to allow a migration to GPLv3 if that seems like | |
427dcb4b JH |
101 | EOF |
102 | ||
c3e7fbcb | 103 | test_expect_success \ |
b6d8f309 JH |
104 | 'validate output from rename/copy detection (#2)' \ |
105 | 'compare_diff_patch current expected' | |
c3e7fbcb JH |
106 | |
107 | test_expect_success \ | |
108 | 'prepare work tree once again' \ | |
109 | 'cat ../../COPYING >COPYING && | |
110 | git-update-cache --add --remove COPYING COPYING.1' | |
111 | ||
f7c1512a JH |
112 | # tree has COPYING and rezrov. work tree has COPYING and COPYING.1, |
113 | # but COPYING is not edited. We say you copy-and-edit COPYING.1; this | |
114 | # is only possible because -C mode now reports the unmodified file to | |
115 | # the diff-core. Unchanged rezrov, although being fed to | |
116 | # git-diff-cache as well, should not be mentioned. | |
c3e7fbcb | 117 | |
b6d8f309 | 118 | GIT_DIFF_OPTS=--unified=0 git-diff-cache -C -p $tree >current |
c3e7fbcb | 119 | cat >expected <<\EOF |
b6d8f309 | 120 | diff --git a/COPYING b/COPYING.1 |
c3e7fbcb | 121 | copy from COPYING |
b6d8f309 | 122 | copy to COPYING.1 |
c3e7fbcb | 123 | --- a/COPYING |
b6d8f309 JH |
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 | |
c3e7fbcb JH |
128 | EOF |
129 | ||
427dcb4b | 130 | test_expect_success \ |
b6d8f309 JH |
131 | 'validate output from rename/copy detection (#3)' \ |
132 | 'compare_diff_patch current expected' | |
427dcb4b JH |
133 | |
134 | test_done |