]>
Commit | Line | Data |
---|---|---|
5ab9cc86 | 1 | #!/bin/sh |
fe142b3a RR |
2 | # |
3 | # Copyright (c) Robin Rosenberg | |
4 | # | |
5 | test_description='CVS export comit. ' | |
6 | ||
7 | . ./test-lib.sh | |
8 | ||
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 | |
15 | fi | |
16 | ||
e32139aa EW |
17 | CVSROOT=$(pwd)/cvsroot |
18 | CVSWORK=$(pwd)/cvswork | |
19 | GIT_DIR=$(pwd)/.git | |
20 | export CVSROOT CVSWORK GIT_DIR | |
21 | ||
fe142b3a RR |
22 | rm -rf "$CVSROOT" "$CVSWORK" |
23 | mkdir "$CVSROOT" && | |
24 | cvs init && | |
25 | cvs -Q co -d "$CVSWORK" . && | |
fe142b3a RR |
26 | echo >empty && |
27 | git add empty && | |
e32139aa | 28 | git commit -q -a -m "Initial" 2>/dev/null || |
fe142b3a RR |
29 | exit 1 |
30 | ||
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 | |
54 | )' | |
55 | ||
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 | |
80 | )' | |
81 | ||
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 | |
92 | )' | |
93 | ||
e86ad71f RR |
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 | # )' | |
fe142b3a RR |
105 | |
106 | # We reuse the state from two tests back here | |
107 | ||
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' \ | |
e86ad71f | 112 | 'git reset --hard HEAD^^ && |
fe142b3a RR |
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 | |
127 | )' | |
128 | ||
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 | |
144 | )' | |
145 | ||
e86ad71f RR |
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/" | |
158 | )' | |
159 | ||
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/" | |
170 | )' | |
171 | ||
172 | # This test contains ISO-8859-1 characters | |
173 | test_expect_success \ | |
174 | 'File with non-ascii file name' \ | |
175 |