packv4: nth_packed_object_sha1() packv4 support
[git/packv4.git] / t / t9200-git-cvsexportcommit.sh
blob910c584f242c6b29fc6d398d2433703765abbcc5
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 check_entries () {
32 # $1 == directory, $2 == expected
33 grep '^/' "$1/CVS/Entries" | sort | cut -d/ -f2,3,5 >actual
34 if test -z "$2"
35 then
36 >expected
37 else
38 printf '%s\n' "$2" | tr '|' '\012' >expected
40 diff -u expected actual
43 test_expect_success \
44 'New file' \
45 'mkdir A B C D E F &&
46 echo hello1 >A/newfile1.txt &&
47 echo hello2 >B/newfile2.txt &&
48 cp ../test9200a.png C/newfile3.png &&
49 cp ../test9200a.png D/newfile4.png &&
50 git add A/newfile1.txt &&
51 git add B/newfile2.txt &&
52 git add C/newfile3.png &&
53 git add D/newfile4.png &&
54 git commit -a -m "Test: New file" &&
55 id=$(git rev-list --max-count=1 HEAD) &&
56 (cd "$CVSWORK" &&
57 git cvsexportcommit -c $id &&
58 check_entries A "newfile1.txt/1.1/" &&
59 check_entries B "newfile2.txt/1.1/" &&
60 check_entries C "newfile3.png/1.1/-kb" &&
61 check_entries D "newfile4.png/1.1/-kb" &&
62 diff A/newfile1.txt ../A/newfile1.txt &&
63 diff B/newfile2.txt ../B/newfile2.txt &&
64 diff C/newfile3.png ../C/newfile3.png &&
65 diff D/newfile4.png ../D/newfile4.png
68 test_expect_success \
69 'Remove two files, add two and update two' \
70 'echo Hello1 >>A/newfile1.txt &&
71 rm -f B/newfile2.txt &&
72 rm -f C/newfile3.png &&
73 echo Hello5 >E/newfile5.txt &&
74 cp ../test9200b.png D/newfile4.png &&
75 cp ../test9200a.png F/newfile6.png &&
76 git add E/newfile5.txt &&
77 git add F/newfile6.png &&
78 git commit -a -m "Test: Remove, add and update" &&
79 id=$(git rev-list --max-count=1 HEAD) &&
80 (cd "$CVSWORK" &&
81 git cvsexportcommit -c $id &&
82 check_entries A "newfile1.txt/1.2/" &&
83 check_entries B "" &&
84 check_entries C "" &&
85 check_entries D "newfile4.png/1.2/-kb" &&
86 check_entries E "newfile5.txt/1.1/" &&
87 check_entries F "newfile6.png/1.1/-kb" &&
88 diff A/newfile1.txt ../A/newfile1.txt &&
89 diff D/newfile4.png ../D/newfile4.png &&
90 diff E/newfile5.txt ../E/newfile5.txt &&
91 diff F/newfile6.png ../F/newfile6.png
94 # Should fail (but only on the git-cvsexportcommit stage)
95 test_expect_success \
96 'Fail to change binary more than one generation old' \
97 'cat F/newfile6.png >>D/newfile4.png &&
98 git commit -a -m "generatiion 1" &&
99 cat F/newfile6.png >>D/newfile4.png &&
100 git commit -a -m "generation 2" &&
101 id=$(git rev-list --max-count=1 HEAD) &&
102 (cd "$CVSWORK" &&
103 ! git cvsexportcommit -c $id
106 #test_expect_success \
107 # 'Fail to remove binary file more than one generation old' \
108 # 'git reset --hard HEAD^ &&
109 # cat F/newfile6.png >>D/newfile4.png &&
110 # git commit -a -m "generation 2 (again)" &&
111 # rm -f D/newfile4.png &&
112 # git commit -a -m "generation 3" &&
113 # id=$(git rev-list --max-count=1 HEAD) &&
114 # (cd "$CVSWORK" &&
115 # ! git cvsexportcommit -c $id
116 # )'
118 # We reuse the state from two tests back here
120 # This test is here because a patch for only binary files will
121 # fail with gnu patch, so cvsexportcommit must handle that.
122 test_expect_success \
123 'Remove only binary files' \
124 'git reset --hard HEAD^^ &&
125 rm -f D/newfile4.png &&
126 git commit -a -m "test: remove only a binary file" &&
127 id=$(git rev-list --max-count=1 HEAD) &&
128 (cd "$CVSWORK" &&
129 git cvsexportcommit -c $id &&
130 check_entries A "newfile1.txt/1.2/" &&
131 check_entries B "" &&
132 check_entries C "" &&
133 check_entries D "" &&
134 check_entries E "newfile5.txt/1.1/" &&
135 check_entries F "newfile6.png/1.1/-kb" &&
136 diff A/newfile1.txt ../A/newfile1.txt &&
137 diff E/newfile5.txt ../E/newfile5.txt &&
138 diff F/newfile6.png ../F/newfile6.png
141 test_expect_success \
142 'Remove only a text file' \
143 'rm -f A/newfile1.txt &&
144 git commit -a -m "test: remove only a binary file" &&
145 id=$(git rev-list --max-count=1 HEAD) &&
146 (cd "$CVSWORK" &&
147 git cvsexportcommit -c $id &&
148 check_entries A "" &&
149 check_entries B "" &&
150 check_entries C "" &&
151 check_entries D "" &&
152 check_entries E "newfile5.txt/1.1/" &&
153 check_entries F "newfile6.png/1.1/-kb" &&
154 diff E/newfile5.txt ../E/newfile5.txt &&
155 diff F/newfile6.png ../F/newfile6.png
158 test_expect_success \
159 'New file with spaces in file name' \
160 'mkdir "G g" &&
161 echo ok then >"G g/with spaces.txt" &&
162 git add "G g/with spaces.txt" && \
163 cp ../test9200a.png "G g/with spaces.png" && \
164 git add "G g/with spaces.png" &&
165 git commit -a -m "With spaces" &&
166 id=$(git rev-list --max-count=1 HEAD) &&
167 (cd "$CVSWORK" &&
168 git-cvsexportcommit -c $id &&
169 check_entries "G g" "with spaces.png/1.1/-kb|with spaces.txt/1.1/"
172 test_expect_success \
173 'Update file with spaces in file name' \
174 'echo Ok then >>"G g/with spaces.txt" &&
175 cat ../test9200a.png >>"G g/with spaces.png" && \
176 git add "G g/with spaces.png" &&
177 git commit -a -m "Update with spaces" &&
178 id=$(git rev-list --max-count=1 HEAD) &&
179 (cd "$CVSWORK" &&
180 git-cvsexportcommit -c $id
181 check_entries "G g" "with spaces.png/1.2/-kb|with spaces.txt/1.2/"
184 # Some filesystems mangle pathnames with UTF-8 characters --
185 # check and skip
186 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/å/ä/ö" &&
187 mkdir -p "tst/$p" &&
188 date >"tst/$p/day" &&
189 found=$(find tst -type f -print) &&
190 test "z$found" = "ztst/$p/day" &&
191 rm -fr tst
192 then
194 # This test contains UTF-8 characters
195 test_expect_success \
196 'File with non-ascii file name' \
197 '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/å/ä/ö &&
198 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 &&
199 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 &&
200 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 &&
201 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 &&
202 git commit -a -m "Går det så går det" && \
203 id=$(git rev-list --max-count=1 HEAD) &&
204 (cd "$CVSWORK" &&
205 git-cvsexportcommit -v -c $id &&
206 check_entries \
207 "Å/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/å/ä/ö" \
208 "gårdetsågårdet.png/1.1/-kb|gårdetsågårdet.txt/1.1/"
213 rm -fr tst
215 test_expect_success \
216 'Mismatching patch should fail' \
217 'date >>"E/newfile5.txt" &&
218 git add "E/newfile5.txt" &&
219 git commit -a -m "Update one" &&
220 date >>"E/newfile5.txt" &&
221 git add "E/newfile5.txt" &&
222 git commit -a -m "Update two" &&
223 id=$(git rev-list --max-count=1 HEAD) &&
224 (cd "$CVSWORK" &&
225 ! git-cvsexportcommit -c $id
228 case "$(git repo-config --bool core.filemode)" in
229 false)
232 test_expect_success \
233 'Retain execute bit' \
234 'mkdir G &&
235 echo executeon >G/on &&
236 chmod +x G/on &&
237 echo executeoff >G/off &&
238 git add G/on &&
239 git add G/off &&
240 git commit -a -m "Execute test" &&
241 (cd "$CVSWORK" &&
242 git-cvsexportcommit -c HEAD
243 test -x G/on &&
244 ! test -x G/off
247 esac
249 test_done