Initial bulk commit for "Git on MSys"
[msysgit/historical-msysgit.git] / git / t / t9200-git-cvsexportcommit.sh
blobf7936e87da248acea8ae94f198c5d7cf16d1fafe
1 #!/bin/sh
3 # Copyright (c) Robin Rosenberg
5 test_description='CVS export comit. '
7 . ./test-lib.sh
9 say "CVS does not work on MinGW, skipping tests."
10 test_done
11 exit 0
13 cvs >/dev/null 2>&1
14 if test $? -ne 1
15 then
16 test_expect_success 'skipping git-cvsexportcommit tests, cvs not found' :
17 test_done
18 exit
21 CVSROOT=$(pwd)/cvsroot
22 CVSWORK=$(pwd)/cvswork
23 GIT_DIR=$(pwd)/.git
24 export CVSROOT CVSWORK GIT_DIR
26 rm -rf "$CVSROOT" "$CVSWORK"
27 mkdir "$CVSROOT" &&
28 cvs init &&
29 cvs -Q co -d "$CVSWORK" . &&
30 echo >empty &&
31 git add empty &&
32 git commit -q -a -m "Initial" 2>/dev/null ||
33 exit 1
35 test_expect_success \
36 'New file' \
37 'mkdir A B C D E F &&
38 echo hello1 >A/newfile1.txt &&
39 echo hello2 >B/newfile2.txt &&
40 cp ../test9200a.png C/newfile3.png &&
41 cp ../test9200a.png D/newfile4.png &&
42 git add A/newfile1.txt &&
43 git add B/newfile2.txt &&
44 git add C/newfile3.png &&
45 git add D/newfile4.png &&
46 git commit -a -m "Test: New file" &&
47 id=$(git rev-list --max-count=1 HEAD) &&
48 (cd "$CVSWORK" &&
49 git cvsexportcommit -c $id &&
50 test "$(echo $(/usr/bin/sort A/CVS/Entries|cut -d/ -f2,3,5))" = "newfile1.txt/1.1/" &&
51 test "$(echo $(/usr/bin/sort B/CVS/Entries|cut -d/ -f2,3,5))" = "newfile2.txt/1.1/" &&
52 test "$(echo $(/usr/bin/sort C/CVS/Entries|cut -d/ -f2,3,5))" = "newfile3.png/1.1/-kb" &&
53 test "$(echo $(/usr/bin/sort D/CVS/Entries|cut -d/ -f2,3,5))" = "newfile4.png/1.1/-kb" &&
54 diff A/newfile1.txt ../A/newfile1.txt &&
55 diff B/newfile2.txt ../B/newfile2.txt &&
56 diff C/newfile3.png ../C/newfile3.png &&
57 diff D/newfile4.png ../D/newfile4.png
60 test_expect_success \
61 'Remove two files, add two and update two' \
62 'echo Hello1 >>A/newfile1.txt &&
63 rm -f B/newfile2.txt &&
64 rm -f C/newfile3.png &&
65 echo Hello5 >E/newfile5.txt &&
66 cp ../test9200b.png D/newfile4.png &&
67 cp ../test9200a.png F/newfile6.png &&
68 git add E/newfile5.txt &&
69 git add F/newfile6.png &&
70 git commit -a -m "Test: Remove, add and update" &&
71 id=$(git rev-list --max-count=1 HEAD) &&
72 (cd "$CVSWORK" &&
73 git cvsexportcommit -c $id &&
74 test "$(echo $(/usr/bin/sort A/CVS/Entries|cut -d/ -f2,3,5))" = "newfile1.txt/1.2/" &&
75 test "$(echo $(/usr/bin/sort B/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
76 test "$(echo $(/usr/bin/sort C/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
77 test "$(echo $(/usr/bin/sort D/CVS/Entries|cut -d/ -f2,3,5))" = "newfile4.png/1.2/-kb" &&
78 test "$(echo $(/usr/bin/sort E/CVS/Entries|cut -d/ -f2,3,5))" = "newfile5.txt/1.1/" &&
79 test "$(echo $(/usr/bin/sort F/CVS/Entries|cut -d/ -f2,3,5))" = "newfile6.png/1.1/-kb" &&
80 diff A/newfile1.txt ../A/newfile1.txt &&
81 diff D/newfile4.png ../D/newfile4.png &&
82 diff E/newfile5.txt ../E/newfile5.txt &&
83 diff F/newfile6.png ../F/newfile6.png
86 # Should fail (but only on the git-cvsexportcommit stage)
87 test_expect_success \
88 'Fail to change binary more than one generation old' \
89 'cat F/newfile6.png >>D/newfile4.png &&
90 git commit -a -m "generatiion 1" &&
91 cat F/newfile6.png >>D/newfile4.png &&
92 git commit -a -m "generation 2" &&
93 id=$(git rev-list --max-count=1 HEAD) &&
94 (cd "$CVSWORK" &&
95 ! git cvsexportcommit -c $id
98 #test_expect_success \
99 # 'Fail to remove binary file more than one generation old' \
100 # 'git reset --hard HEAD^ &&
101 # cat F/newfile6.png >>D/newfile4.png &&
102 # git commit -a -m "generation 2 (again)" &&
103 # rm -f D/newfile4.png &&
104 # git commit -a -m "generation 3" &&
105 # id=$(git rev-list --max-count=1 HEAD) &&
106 # (cd "$CVSWORK" &&
107 # ! git cvsexportcommit -c $id
108 # )'
110 # We reuse the state from two tests back here
112 # This test is here because a patch for only binary files will
113 # fail with gnu patch, so cvsexportcommit must handle that.
114 test_expect_success \
115 'Remove only binary files' \
116 'git reset --hard HEAD^^ &&
117 rm -f D/newfile4.png &&
118 git commit -a -m "test: remove only a binary file" &&
119 id=$(git rev-list --max-count=1 HEAD) &&
120 (cd "$CVSWORK" &&
121 git cvsexportcommit -c $id &&
122 test "$(echo $(/usr/bin/sort A/CVS/Entries|cut -d/ -f2,3,5))" = "newfile1.txt/1.2/" &&
123 test "$(echo $(/usr/bin/sort B/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
124 test "$(echo $(/usr/bin/sort C/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
125 test "$(echo $(/usr/bin/sort D/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
126 test "$(echo $(/usr/bin/sort E/CVS/Entries|cut -d/ -f2,3,5))" = "newfile5.txt/1.1/" &&
127 test "$(echo $(/usr/bin/sort F/CVS/Entries|cut -d/ -f2,3,5))" = "newfile6.png/1.1/-kb" &&
128 diff A/newfile1.txt ../A/newfile1.txt &&
129 diff E/newfile5.txt ../E/newfile5.txt &&
130 diff F/newfile6.png ../F/newfile6.png
133 test_expect_success \
134 'Remove only a text file' \
135 'rm -f A/newfile1.txt &&
136 git commit -a -m "test: remove only a binary file" &&
137 id=$(git rev-list --max-count=1 HEAD) &&
138 (cd "$CVSWORK" &&
139 git cvsexportcommit -c $id &&
140 test "$(echo $(/usr/bin/sort A/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
141 test "$(echo $(/usr/bin/sort B/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
142 test "$(echo $(/usr/bin/sort C/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
143 test "$(echo $(/usr/bin/sort D/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
144 test "$(echo $(/usr/bin/sort E/CVS/Entries|cut -d/ -f2,3,5))" = "newfile5.txt/1.1/" &&
145 test "$(echo $(/usr/bin/sort F/CVS/Entries|cut -d/ -f2,3,5))" = "newfile6.png/1.1/-kb" &&
146 diff E/newfile5.txt ../E/newfile5.txt &&
147 diff F/newfile6.png ../F/newfile6.png
150 test_expect_success \
151 'New file with spaces in file name' \
152 'mkdir "G g" &&
153 echo ok then >"G g/with spaces.txt" &&
154 git add "G g/with spaces.txt" && \
155 cp ../test9200a.png "G g/with spaces.png" && \
156 git add "G g/with spaces.png" &&
157 git commit -a -m "With spaces" &&
158 id=$(git rev-list --max-count=1 HEAD) &&
159 (cd "$CVSWORK" &&
160 git-cvsexportcommit -c $id &&
161 test "$(echo $(/usr/bin/sort "G g/CVS/Entries"|cut -d/ -f2,3,5))" = "with spaces.png/1.1/-kb with spaces.txt/1.1/"
164 test_expect_success \
165 'Update file with spaces in file name' \
166 'echo Ok then >>"G g/with spaces.txt" &&
167 cat ../test9200a.png >>"G g/with spaces.png" && \
168 git add "G g/with spaces.png" &&
169 git commit -a -m "Update with spaces" &&
170 id=$(git rev-list --max-count=1 HEAD) &&
171 (cd "$CVSWORK" &&
172 git-cvsexportcommit -c $id
173 test "$(echo $(/usr/bin/sort "G g/CVS/Entries"|cut -d/ -f2,3,5))" = "with spaces.png/1.2/-kb with spaces.txt/1.2/"
176 # Some filesystems mangle pathnames with UTF-8 characters --
177 # check and skip
178 if 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/å/ä/ö" &&
179 mkdir -p "tst/$p" &&
180 date >"tst/$p/day" &&
181 found=$(/usr/bin/find tst -type f -print) &&
182 test "z$found" = "ztst/$p/day" &&
183 rm -fr tst
184 then
186 # This test contains UTF-8 characters
187 test_expect_success \
188 'File with non-ascii file name' \
189 '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/å/ä/ö &&
190 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 &&
191 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 &&
192 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 &&
193 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 &&
194 git commit -a -m "Går det så går det" && \
195 id=$(git rev-list --max-count=1 HEAD) &&
196 (cd "$CVSWORK" &&
197 git-cvsexportcommit -v -c $id &&
198 test "$(echo $(/usr/bin/sortsort Å/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/"
203 rm -fr tst
205 test_expect_success \
206 'Mismatching patch should fail' \
207 'date >>"E/newfile5.txt" &&
208 git add "E/newfile5.txt" &&
209 git commit -a -m "Update one" &&
210 date >>"E/newfile5.txt" &&
211 git add "E/newfile5.txt" &&
212 git commit -a -m "Update two" &&
213 id=$(git rev-list --max-count=1 HEAD) &&
214 (cd "$CVSWORK" &&
215 ! git-cvsexportcommit -c $id
218 case "$(git repo-config --bool core.filemode)" in
219 false)
222 test_expect_success \
223 'Retain execute bit' \
224 'mkdir G &&
225 echo executeon >G/on &&
226 chmod +x G/on &&
227 echo executeoff >G/off &&
228 git add G/on &&
229 git add G/off &&
230 git commit -a -m "Execute test" &&
231 (cd "$CVSWORK" &&
232 git-cvsexportcommit -c HEAD
233 test -x G/on &&
234 ! test -x G/off
237 esac
239 test_done