3 # Copyright (c) Robin Rosenberg
5 test_description='CVS export comit. '
12 test_expect_success 'skipping git-cvsexportcommit tests, cvs not found' :
17 CVSROOT=$(pwd)/cvsroot
18 CVSWORK=$(pwd)/cvswork
20 export CVSROOT CVSWORK GIT_DIR
22 rm -rf "$CVSROOT" "$CVSWORK"
25 cvs -Q co -d "$CVSWORK" . &&
28 git commit -q -a -m "Initial" 2>/dev/null ||
34 echo hello1 >A/newfile1.txt &&
35 echo hello2 >B/newfile2.txt &&
36 cp ../test9200a.png C/newfile3.png &&
37 cp ../test9200a.png D/newfile4.png &&
38 git add A/newfile1.txt &&
39 git add B/newfile2.txt &&
40 git add C/newfile3.png &&
41 git add D/newfile4.png &&
42 git commit -a -m "Test: New file" &&
43 id=$(git rev-list --max-count=1 HEAD) &&
45 git cvsexportcommit -c $id &&
46 test "$(echo $(sort A/CVS/Entries|cut -d/ -f2,3,5))" = "newfile1.txt/1.1/" &&
47 test "$(echo $(sort B/CVS/Entries|cut -d/ -f2,3,5))" = "newfile2.txt/1.1/" &&
48 test "$(echo $(sort C/CVS/Entries|cut -d/ -f2,3,5))" = "newfile3.png/1.1/-kb" &&
49 test "$(echo $(sort D/CVS/Entries|cut -d/ -f2,3,5))" = "newfile4.png/1.1/-kb" &&
50 diff A/newfile1.txt ../A/newfile1.txt &&
51 diff B/newfile2.txt ../B/newfile2.txt &&
52 diff C/newfile3.png ../C/newfile3.png &&
53 diff D/newfile4.png ../D/newfile4.png
57 'Remove two files, add two and update two' \
58 'echo Hello1 >>A/newfile1.txt &&
59 rm -f B/newfile2.txt &&
60 rm -f C/newfile3.png &&
61 echo Hello5 >E/newfile5.txt &&
62 cp ../test9200b.png D/newfile4.png &&
63 cp ../test9200a.png F/newfile6.png &&
64 git add E/newfile5.txt &&
65 git add F/newfile6.png &&
66 git commit -a -m "Test: Remove, add and update" &&
67 id=$(git rev-list --max-count=1 HEAD) &&
69 git cvsexportcommit -c $id &&
70 test "$(echo $(sort A/CVS/Entries|cut -d/ -f2,3,5))" = "newfile1.txt/1.2/" &&
71 test "$(echo $(sort B/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
72 test "$(echo $(sort C/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
73 test "$(echo $(sort D/CVS/Entries|cut -d/ -f2,3,5))" = "newfile4.png/1.2/-kb" &&
74 test "$(echo $(sort E/CVS/Entries|cut -d/ -f2,3,5))" = "newfile5.txt/1.1/" &&
75 test "$(echo $(sort F/CVS/Entries|cut -d/ -f2,3,5))" = "newfile6.png/1.1/-kb" &&
76 diff A/newfile1.txt ../A/newfile1.txt &&
77 diff D/newfile4.png ../D/newfile4.png &&
78 diff E/newfile5.txt ../E/newfile5.txt &&
79 diff F/newfile6.png ../F/newfile6.png
82 # Should fail (but only on the git-cvsexportcommit stage)
84 'Fail to change binary more than one generation old' \
85 'cat F/newfile6.png >>D/newfile4.png &&
86 git commit -a -m "generatiion 1" &&
87 cat F/newfile6.png >>D/newfile4.png &&
88 git commit -a -m "generation 2" &&
89 id=$(git rev-list --max-count=1 HEAD) &&
91 ! git cvsexportcommit -c $id
94 #test_expect_success \
95 # 'Fail to remove binary file more than one generation old' \
96 # 'git reset --hard HEAD^ &&
97 # cat F/newfile6.png >>D/newfile4.png &&
98 # git commit -a -m "generation 2 (again)" &&
99 # rm -f D/newfile4.png &&
100 # git commit -a -m "generation 3" &&
101 # id=$(git rev-list --max-count=1 HEAD) &&
103 # ! git cvsexportcommit -c $id
106 # We reuse the state from two tests back here
108 # This test is here because a patch for only binary files will
109 # fail with gnu patch, so cvsexportcommit must handle that.
110 test_expect_success \
111 'Remove only binary files' \
112 'git reset --hard HEAD^^ &&
113 rm -f D/newfile4.png &&
114 git commit -a -m "test: remove only a binary file" &&
115 id=$(git rev-list --max-count=1 HEAD) &&
117 git cvsexportcommit -c $id &&
118 test "$(echo $(sort A/CVS/Entries|cut -d/ -f2,3,5))" = "newfile1.txt/1.2/" &&
119 test "$(echo $(sort B/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
120 test "$(echo $(sort C/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
121 test "$(echo $(sort D/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
122 test "$(echo $(sort E/CVS/Entries|cut -d/ -f2,3,5))" = "newfile5.txt/1.1/" &&
123 test "$(echo $(sort F/CVS/Entries|cut -d/ -f2,3,5))" = "newfile6.png/1.1/-kb" &&
124 diff A/newfile1.txt ../A/newfile1.txt &&
125 diff E/newfile5.txt ../E/newfile5.txt &&
126 diff F/newfile6.png ../F/newfile6.png
129 test_expect_success \
130 'Remove only a text file' \
131 'rm -f A/newfile1.txt &&
132 git commit -a -m "test: remove only a binary file" &&
133 id=$(git rev-list --max-count=1 HEAD) &&
135 git cvsexportcommit -c $id &&
136 test "$(echo $(sort A/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
137 test "$(echo $(sort B/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
138 test "$(echo $(sort C/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
139 test "$(echo $(sort D/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
140 test "$(echo $(sort E/CVS/Entries|cut -d/ -f2,3,5))" = "newfile5.txt/1.1/" &&
141 test "$(echo $(sort F/CVS/Entries|cut -d/ -f2,3,5))" = "newfile6.png/1.1/-kb" &&
142 diff E/newfile5.txt ../E/newfile5.txt &&
143 diff F/newfile6.png ../F/newfile6.png
146 test_expect_success \
147 'New file with spaces in file name' \
149 echo ok then >"G g/with spaces.txt" &&
150 git add "G g/with spaces.txt" && \
151 cp ../test9200a.png "G g/with spaces.png" && \
152 git add "G g/with spaces.png" &&
153 git commit -a -m "With spaces" &&
154 id=$(git rev-list --max-count=1 HEAD) &&
156 git-cvsexportcommit -c $id &&
157 test "$(echo $(sort "G g/CVS/Entries"|cut -d/ -f2,3,5))" = "with spaces.png/1.1/-kb with spaces.txt/1.1/"
160 test_expect_success \
161 'Update file with spaces in file name' \
162 'echo Ok then >>"G g/with spaces.txt" &&
163 cat ../test9200a.png >>"G g/with spaces.png" && \
164 git add "G g/with spaces.png" &&
165 git commit -a -m "Update with spaces" &&
166 id=$(git rev-list --max-count=1 HEAD) &&
168 git-cvsexportcommit -c $id
169 test "$(echo $(sort "G g/CVS/Entries"|cut -d/ -f2,3,5))" = "with spaces.png/1.2/-kb with spaces.txt/1.2/"
172 # This test contains ISO-8859-1 characters
173 test_expect_success \
174 'File with non-ascii file name' \
175 '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/å/ä/ö &&
176 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 &&
177 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 &&
178 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 &&
179 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 &&
180 git commit -a -m "Går det så går det" && \
181 id=$(git rev-list --max-count=1 HEAD) &&
183 git-cvsexportcommit -v -c $id &&
184 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/"
187 test_expect_success \
188 'Mismatching patch should fail' \
189 'date >>"E/newfile5.txt" &&
190 git add "E/newfile5.txt" &&
191 git commit -a -m "Update one" &&
192 date >>"E/newfile5.txt" &&
193 git add "E/newfile5.txt" &&
194 git commit -a -m "Update two" &&
195 id=$(git rev-list --max-count=1 HEAD) &&
197 ! git-cvsexportcommit -c $id
200 test_expect_success \
201 'Retain execute bit' \
203 echo executeon >G/on &&
205 echo executeoff >G/off &&
208 git commit -a -m "Execute test" &&
210 git-cvsexportcommit -c HEAD