1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
|
#!/bin/bash
#
# Copyright (c) Robin Rosenberg
#
test_description='CVS export comit. '
. ./test-lib.sh
cvs >/dev/null 2>&1
if test $? -ne 1
then
test_expect_success 'skipping git-cvsexportcommit tests, cvs not found' :
test_done
exit
fi
export CVSROOT=$(pwd)/cvsroot
export CVSWORK=$(pwd)/cvswork
rm -rf "$CVSROOT" "$CVSWORK"
mkdir "$CVSROOT" &&
cvs init &&
cvs -Q co -d "$CVSWORK" . &&
export GIT_DIR=$(pwd)/.git &&
echo >empty &&
git add empty &&
git commit -a -m "Initial" 2>/dev/null ||
exit 1
test_expect_success \
'New file' \
'mkdir A B C D E F &&
echo hello1 >A/newfile1.txt &&
echo hello2 >B/newfile2.txt &&
cp ../test9200a.png C/newfile3.png &&
cp ../test9200a.png D/newfile4.png &&
git add A/newfile1.txt &&
git add B/newfile2.txt &&
git add C/newfile3.png &&
git add D/newfile4.png &&
git commit -a -m "Test: New file" &&
id=$(git rev-list --max-count=1 HEAD) &&
(cd "$CVSWORK" &&
git cvsexportcommit -c $id &&
test "$(echo $(sort A/CVS/Entries|cut -d/ -f2,3,5))" = "newfile1.txt/1.1/" &&
test "$(echo $(sort B/CVS/Entries|cut -d/ -f2,3,5))" = "newfile2.txt/1.1/" &&
test "$(echo $(sort C/CVS/Entries|cut -d/ -f2,3,5))" = "newfile3.png/1.1/-kb" &&
test "$(echo $(sort D/CVS/Entries|cut -d/ -f2,3,5))" = "newfile4.png/1.1/-kb" &&
diff A/newfile1.txt ../A/newfile1.txt &&
diff B/newfile2.txt ../B/newfile2.txt &&
diff C/newfile3.png ../C/newfile3.png &&
diff D/newfile4.png ../D/newfile4.png
)'
test_expect_success \
'Remove two files, add two and update two' \
'echo Hello1 >>A/newfile1.txt &&
rm -f B/newfile2.txt &&
rm -f C/newfile3.png &&
echo Hello5 >E/newfile5.txt &&
cp ../test9200b.png D/newfile4.png &&
cp ../test9200a.png F/newfile6.png &&
git add E/newfile5.txt &&
git add F/newfile6.png &&
git commit -a -m "Test: Remove, add and update" &&
id=$(git rev-list --max-count=1 HEAD) &&
(cd "$CVSWORK" &&
git cvsexportcommit -c $id &&
test "$(echo $(sort A/CVS/Entries|cut -d/ -f2,3,5))" = "newfile1.txt/1.2/" &&
test "$(echo $(sort B/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
test "$(echo $(sort C/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
test "$(echo $(sort D/CVS/Entries|cut -d/ -f2,3,5))" = "newfile4.png/1.2/-kb" &&
test "$(echo $(sort E/CVS/Entries|cut -d/ -f2,3,5))" = "newfile5.txt/1.1/" &&
test "$(echo $(sort F/CVS/Entries|cut -d/ -f2,3,5))" = "newfile6.png/1.1/-kb" &&
diff A/newfile1.txt ../A/newfile1.txt &&
diff D/newfile4.png ../D/newfile4.png &&
diff E/newfile5.txt ../E/newfile5.txt &&
diff F/newfile6.png ../F/newfile6.png
)'
# Should fail (but only on the git-cvsexportcommit stage)
test_expect_success \
'Fail to change binary more than one generation old' \
'cat F/newfile6.png >>D/newfile4.png &&
git commit -a -m "generatiion 1" &&
cat F/newfile6.png >>D/newfile4.png &&
git commit -a -m "generation 2" &&
id=$(git rev-list --max-count=1 HEAD) &&
(cd "$CVSWORK" &&
! git cvsexportcommit -c $id
)'
#test_expect_success \
# 'Fail to remove binary file more than one generation old' \
# 'git reset --hard HEAD^ &&
# cat F/newfile6.png >>D/newfile4.png &&
# git commit -a -m "generation 2 (again)" &&
# rm -f D/newfile4.png &&
# git commit -a -m "generation 3" &&
# id=$(git rev-list --max-count=1 HEAD) &&
# (cd "$CVSWORK" &&
# ! git cvsexportcommit -c $id
# )'
# We reuse the state from two tests back here
# This test is here because a patch for only binary files will
# fail with gnu patch, so cvsexportcommit must handle that.
test_expect_success \
'Remove only binary files' \
'git reset --hard HEAD^^ &&
rm -f D/newfile4.png &&
git commit -a -m "test: remove only a binary file" &&
id=$(git rev-list --max-count=1 HEAD) &&
(cd "$CVSWORK" &&
git cvsexportcommit -c $id &&
test "$(echo $(sort A/CVS/Entries|cut -d/ -f2,3,5))" = "newfile1.txt/1.2/" &&
test "$(echo $(sort B/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
test "$(echo $(sort C/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
test "$(echo $(sort D/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
test "$(echo $(sort E/CVS/Entries|cut -d/ -f2,3,5))" = "newfile5.txt/1.1/" &&
test "$(echo $(sort F/CVS/Entries|cut -d/ -f2,3,5))" = "newfile6.png/1.1/-kb" &&
diff A/newfile1.txt ../A/newfile1.txt &&
diff E/newfile5.txt ../E/newfile5.txt &&
diff F/newfile6.png ../F/newfile6.png
)'
test_expect_success \
'Remove only a text file' \
'rm -f A/newfile1.txt &&
git commit -a -m "test: remove only a binary file" &&
id=$(git rev-list --max-count=1 HEAD) &&
(cd "$CVSWORK" &&
git cvsexportcommit -c $id &&
test "$(echo $(sort A/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
test "$(echo $(sort B/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
test "$(echo $(sort C/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
test "$(echo $(sort D/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
test "$(echo $(sort E/CVS/Entries|cut -d/ -f2,3,5))" = "newfile5.txt/1.1/" &&
test "$(echo $(sort F/CVS/Entries|cut -d/ -f2,3,5))" = "newfile6.png/1.1/-kb" &&
diff E/newfile5.txt ../E/newfile5.txt &&
diff F/newfile6.png ../F/newfile6.png
)'
test_expect_success \
'New file with spaces in file name' \
'mkdir "G g" &&
echo ok then >"G g/with spaces.txt" &&
git add "G g/with spaces.txt" && \
cp ../test9200a.png "G g/with spaces.png" && \
git add "G g/with spaces.png" &&
git commit -a -m "With spaces" &&
id=$(git rev-list --max-count=1 HEAD) &&
(cd "$CVSWORK" &&
git-cvsexportcommit -c $id &&
test "$(echo $(sort "G g/CVS/Entries"|cut -d/ -f2,3,5))" = "with spaces.png/1.1/-kb with spaces.txt/1.1/"
)'
test_expect_success \
'Update file with spaces in file name' \
'echo Ok then >>"G g/with spaces.txt" &&
cat ../test9200a.png >>"G g/with spaces.png" && \
git add "G g/with spaces.png" &&
git commit -a -m "Update with spaces" &&
id=$(git rev-list --max-count=1 HEAD) &&
(cd "$CVSWORK" &&
git-cvsexportcommit -c $id
test "$(echo $(sort "G g/CVS/Entries"|cut -d/ -f2,3,5))" = "with spaces.png/1.2/-kb with spaces.txt/1.2/"
)'
# This test contains ISO-8859-1 characters
test_expect_success \
'File with non-ascii file name' \
'mkdir -p �/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/�/�/� &&
echo Foo >�/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/�/�/�/g�rdets�g�rdet.txt &&
git add �/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/�/�/�/g�rdets�g�rdet.txt &&
cp ../test9200a.png �/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/�/�/�/g�rdets�g�rdet.png &&
git add �/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/�/�/�/g�rdets�g�rdet.png &&
git commit -a -m "G�r det s� g�r det" && \
id=$(git rev-list --max-count=1 HEAD) &&
(cd "$CVSWORK" &&
git-cvsexportcommit -v -c $id &&
test "$(echo $(sort �/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/�/�/�/CVS/Entries|cut -d/ -f2,3,5))" = "g�rdets�g�rdet.png/1.1/-kb g�rdets�g�rdet.txt/1.1/"
)'
test_expect_success \
'Mismatching patch should fail' \
'date >>"E/newfile5.txt" &&
git add "E/newfile5.txt" &&
git commit -a -m "Update one" &&
date >>"E/newfile5.txt" &&
git add "E/newfile5.txt" &&
git commit -a -m "Update two" &&
id=$(git rev-list --max-count=1 HEAD) &&
(cd "$CVSWORK" &&
! git-cvsexportcommit -c $id
)'
test_expect_success \
'Retain execute bit' \
'mkdir G &&
echo executeon >G/on &&
chmod +x G/on &&
echo executeoff >G/off &&
git add G/on &&
git add G/off &&
git commit -a -m "Execute test" &&
(cd "$CVSWORK" &&
git-cvsexportcommit -c HEAD
test -x G/on &&
! test -x G/off
)'
test_done
|