glossary: Add definitions for dangling and unreachable objects
[git/mingw/4msysgit/kblees.git] / t / t9200-git-cvsexportcommit.sh
blob4efa0c926c45befa92be90f746f03807a591a893
1 #!/bin/sh
3 # Copyright (c) Robin Rosenberg
5 test_description='CVS export comit. '
7 . ./test-lib.sh
9 cvs >/dev/null 2>&1
10 if test $? -ne 1
11 then
12 test_expect_success 'skipping git-cvsexportcommit tests, cvs not found' :
13 test_done
14 exit
17 CVSROOT=$(pwd)/cvsroot
18 CVSWORK=$(pwd)/cvswork
19 GIT_DIR=$(pwd)/.git
20 export CVSROOT CVSWORK GIT_DIR
22 rm -rf "$CVSROOT" "$CVSWORK"
23 mkdir "$CVSROOT" &&
24 cvs init &&
25 cvs -Q co -d "$CVSWORK" . &&
26 echo >empty &&
27 git add empty &&
28 git commit -q -a -m "Initial" 2>/dev/null ||
29 exit 1
31 test_expect_success \
32 'New file' \
33 'mkdir A B C D E F &&
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) &&
44 (cd "$CVSWORK" &&
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
56 test_expect_success \
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) &&
68 (cd "$CVSWORK" &&
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)
83 test_expect_success \
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) &&
90 (cd "$CVSWORK" &&
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) &&
102 # (cd "$CVSWORK" &&
103 # ! git cvsexportcommit -c $id
104 # )'
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) &&
116 (cd "$CVSWORK" &&
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) &&
134 (cd "$CVSWORK" &&
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' \
148 'mkdir "G g" &&
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) &&
155 (cd "$CVSWORK" &&
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) &&
167 (cd "$CVSWORK" &&
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 # Some filesystems mangle pathnames with UTF-8 characters --
173 # check and skip
174 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/å/ä/ö" &&
175 mkdir -p "tst/$p" &&
176 date >"tst/$p/day" &&
177 found=$(find tst -type f -print) &&
178 test "z$found" = "ztst/$p/day" &&
179 rm -fr tst
180 then
182 # This test contains UTF-8 characters
183 test_expect_success \
184 'File with non-ascii file name' \
185 '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/å/ä/ö &&
186 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 &&
187 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 &&
188 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 &&
189 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 &&
190 git commit -a -m "Går det så går det" && \
191 id=$(git rev-list --max-count=1 HEAD) &&
192 (cd "$CVSWORK" &&
193 git-cvsexportcommit -v -c $id &&
194 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/"
199 rm -fr tst
201 test_expect_success \
202 'Mismatching patch should fail' \
203 'date >>"E/newfile5.txt" &&
204 git add "E/newfile5.txt" &&
205 git commit -a -m "Update one" &&
206 date >>"E/newfile5.txt" &&
207 git add "E/newfile5.txt" &&
208 git commit -a -m "Update two" &&
209 id=$(git rev-list --max-count=1 HEAD) &&
210 (cd "$CVSWORK" &&
211 ! git-cvsexportcommit -c $id
214 case "$(git repo-config --bool core.filemode)" in
215 false)
218 test_expect_success \
219 'Retain execute bit' \
220 'mkdir G &&
221 echo executeon >G/on &&
222 chmod +x G/on &&
223 echo executeoff >G/off &&
224 git add G/on &&
225 git add G/off &&
226 git commit -a -m "Execute test" &&
227 (cd "$CVSWORK" &&
228 git-cvsexportcommit -c HEAD
229 test -x G/on &&
230 ! test -x G/off
233 esac
235 test_done