]>
Commit | Line | Data |
---|---|---|
f2dc849e JS |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2007 Johannes E. Schindelin | |
4 | # | |
5 | ||
eaa2a6fc | 6 | test_description='git fast-export' |
f2dc849e JS |
7 | . ./test-lib.sh |
8 | ||
9 | test_expect_success 'setup' ' | |
10 | ||
ebeec7db EN |
11 | echo break it > file0 && |
12 | git add file0 && | |
13 | test_tick && | |
f2dc849e JS |
14 | echo Wohlauf > file && |
15 | git add file && | |
16 | test_tick && | |
17 | git commit -m initial && | |
18 | echo die Luft > file && | |
19 | echo geht frisch > file2 && | |
20 | git add file file2 && | |
21 | test_tick && | |
22 | git commit -m second && | |
23 | echo und > file2 && | |
24 | test_tick && | |
25 | git commit -m third file2 && | |
26 | test_tick && | |
27 | git tag rein && | |
28 | git checkout -b wer HEAD^ && | |
29 | echo lange > file2 | |
30 | test_tick && | |
31 | git commit -m sitzt file2 && | |
32 | test_tick && | |
33 | git tag -a -m valentin muss && | |
34 | git merge -s ours master | |
35 | ||
36 | ' | |
37 | ||
38 | test_expect_success 'fast-export | fast-import' ' | |
39 | ||
40 | MASTER=$(git rev-parse --verify master) && | |
41 | REIN=$(git rev-parse --verify rein) && | |
42 | WER=$(git rev-parse --verify wer) && | |
43 | MUSS=$(git rev-parse --verify muss) && | |
44 | mkdir new && | |
45 | git --git-dir=new/.git init && | |
46 | git fast-export --all | | |
47 | (cd new && | |
48 | git fast-import && | |
49 | test $MASTER = $(git rev-parse --verify refs/heads/master) && | |
50 | test $REIN = $(git rev-parse --verify refs/tags/rein) && | |
51 | test $WER = $(git rev-parse --verify refs/heads/wer) && | |
52 | test $MUSS = $(git rev-parse --verify refs/tags/muss)) | |
53 | ||
54 | ' | |
55 | ||
56 | test_expect_success 'fast-export master~2..master' ' | |
57 | ||
58 | git fast-export master~2..master | | |
59 | sed "s/master/partial/" | | |
60 | (cd new && | |
61 | git fast-import && | |
62 | test $MASTER != $(git rev-parse --verify refs/heads/partial) && | |
ebeec7db EN |
63 | git diff --exit-code master partial && |
64 | git diff --exit-code master^ partial^ && | |
d492b31c | 65 | test_must_fail git rev-parse partial~2) |
f2dc849e JS |
66 | |
67 | ' | |
68 | ||
69 | test_expect_success 'iso-8859-1' ' | |
70 | ||
e0d44c50 | 71 | git config i18n.commitencoding ISO8859-1 && |
f2dc849e | 72 | # use author and committer name in ISO-8859-1 to match it. |
bfdbee98 | 73 | . "$TEST_DIRECTORY"/t3901-8859-1.txt && |
f2dc849e JS |
74 | test_tick && |
75 | echo rosten >file && | |
76 | git commit -s -m den file && | |
77 | git fast-export wer^..wer | | |
78 | sed "s/wer/i18n/" | | |
79 | (cd new && | |
80 | git fast-import && | |
81 | git cat-file commit i18n | grep "Áéí óú") | |
82 | ||
df6a7ff7 PB |
83 | ' |
84 | test_expect_success 'import/export-marks' ' | |
85 | ||
86 | git checkout -b marks master && | |
87 | git fast-export --export-marks=tmp-marks HEAD && | |
88 | test -s tmp-marks && | |
df6a7ff7 PB |
89 | test $(wc -l < tmp-marks) -eq 3 && |
90 | test $( | |
91 | git fast-export --import-marks=tmp-marks\ | |
92 | --export-marks=tmp-marks HEAD | | |
93 | grep ^commit | | |
94 | wc -l) \ | |
95 | -eq 0 && | |
96 | echo change > file && | |
97 | git commit -m "last commit" file && | |
98 | test $( | |
99 | git fast-export --import-marks=tmp-marks \ | |
100 | --export-marks=tmp-marks HEAD | | |
101 | grep ^commit\ | | |
102 | wc -l) \ | |
103 | -eq 1 && | |
104 | test $(wc -l < tmp-marks) -eq 4 | |
105 | ||
f2dc849e JS |
106 | ' |
107 | ||
108 | cat > signed-tag-import << EOF | |
109 | tag sign-your-name | |
110 | from $(git rev-parse HEAD) | |
111 | tagger C O Mitter <committer@example.com> 1112911993 -0700 | |
112 | data 210 | |
113 | A message for a sign | |
114 | -----BEGIN PGP SIGNATURE----- | |
115 | Version: GnuPG v1.4.5 (GNU/Linux) | |
116 | ||
117 | fakedsignaturefakedsignaturefakedsignaturefakedsignaturfakedsign | |
118 | aturefakedsignaturefake= | |
119 | =/59v | |
120 | -----END PGP SIGNATURE----- | |
121 | EOF | |
122 | ||
123 | test_expect_success 'set up faked signed tag' ' | |
124 | ||
125 | cat signed-tag-import | git fast-import | |
126 | ||
127 | ' | |
128 | ||
129 | test_expect_success 'signed-tags=abort' ' | |
130 | ||
d492b31c | 131 | test_must_fail git fast-export --signed-tags=abort sign-your-name |
f2dc849e JS |
132 | |
133 | ' | |
134 | ||
ee4bc371 | 135 | test_expect_success 'signed-tags=verbatim' ' |
f2dc849e | 136 | |
ee4bc371 | 137 | git fast-export --signed-tags=verbatim sign-your-name > output && |
f2dc849e JS |
138 | grep PGP output |
139 | ||
140 | ' | |
141 | ||
142 | test_expect_success 'signed-tags=strip' ' | |
143 | ||
144 | git fast-export --signed-tags=strip sign-your-name > output && | |
145 | ! grep PGP output | |
146 | ||
147 | ' | |
148 | ||
03db4525 AG |
149 | test_expect_success 'setup submodule' ' |
150 | ||
151 | git checkout -f master && | |
152 | mkdir sub && | |
153 | cd sub && | |
154 | git init && | |
155 | echo test file > file && | |
156 | git add file && | |
157 | git commit -m sub_initial && | |
158 | cd .. && | |
159 | git submodule add "`pwd`/sub" sub && | |
160 | git commit -m initial && | |
161 | test_tick && | |
162 | cd sub && | |
163 | echo more data >> file && | |
164 | git add file && | |
165 | git commit -m sub_second && | |
166 | cd .. && | |
167 | git add sub && | |
168 | git commit -m second | |
169 | ||
170 | ' | |
171 | ||
172 | test_expect_success 'submodule fast-export | fast-import' ' | |
173 | ||
174 | SUBENT1=$(git ls-tree master^ sub) && | |
175 | SUBENT2=$(git ls-tree master sub) && | |
176 | rm -rf new && | |
177 | mkdir new && | |
178 | git --git-dir=new/.git init && | |
179 | git fast-export --signed-tags=strip --all | | |
180 | (cd new && | |
181 | git fast-import && | |
182 | test "$SUBENT1" = "$(git ls-tree refs/heads/master^ sub)" && | |
183 | test "$SUBENT2" = "$(git ls-tree refs/heads/master sub)" && | |
184 | git checkout master && | |
185 | git submodule init && | |
186 | git submodule update && | |
187 | cmp sub/file ../sub/file) | |
188 | ||
189 | ' | |
190 | ||
91e80b98 JH |
191 | GIT_AUTHOR_NAME='A U Thor'; export GIT_AUTHOR_NAME |
192 | GIT_COMMITTER_NAME='C O Mitter'; export GIT_COMMITTER_NAME | |
ae7c5dce AG |
193 | |
194 | test_expect_success 'setup copies' ' | |
195 | ||
196 | git config --unset i18n.commitencoding && | |
197 | git checkout -b copy rein && | |
198 | git mv file file3 && | |
199 | git commit -m move1 && | |
200 | test_tick && | |
201 | cp file2 file4 && | |
202 | git add file4 && | |
203 | git mv file2 file5 && | |
204 | git commit -m copy1 && | |
205 | test_tick && | |
206 | cp file3 file6 && | |
207 | git add file6 && | |
208 | git commit -m copy2 && | |
209 | test_tick && | |
210 | echo more text >> file6 && | |
211 | echo even more text >> file6 && | |
212 | git add file6 && | |
213 | git commit -m modify && | |
214 | test_tick && | |
215 | cp file6 file7 && | |
216 | echo test >> file7 && | |
217 | git add file7 && | |
218 | git commit -m copy_modify | |
219 | ||
220 | ' | |
221 | ||
222 | test_expect_success 'fast-export -C -C | fast-import' ' | |
223 | ||
224 | ENTRY=$(git rev-parse --verify copy) && | |
225 | rm -rf new && | |
226 | mkdir new && | |
227 | git --git-dir=new/.git init && | |
228 | git fast-export -C -C --signed-tags=strip --all > output && | |
229 | grep "^C \"file6\" \"file7\"\$" output && | |
230 | cat output | | |
231 | (cd new && | |
232 | git fast-import && | |
233 | test $ENTRY = $(git rev-parse --verify refs/heads/copy)) | |
234 | ||
235 | ' | |
236 | ||
2075ffb5 | 237 | test_expect_success 'fast-export | fast-import when master is tagged' ' |
283b9532 MV |
238 | |
239 | git tag -m msg last && | |
240 | git fast-export -C -C --signed-tags=strip --all > output && | |
241 | test $(grep -c "^tag " output) = 3 | |
242 | ||
243 | ' | |
244 | ||
4e46a8d6 JS |
245 | cat > tag-content << EOF |
246 | object $(git rev-parse HEAD) | |
247 | type commit | |
248 | tag rosten | |
249 | EOF | |
250 | ||
251 | test_expect_success 'cope with tagger-less tags' ' | |
252 | ||
253 | TAG=$(git hash-object -t tag -w tag-content) && | |
254 | git update-ref refs/tags/sonnenschein $TAG && | |
255 | git fast-export -C -C --signed-tags=strip --all > output && | |
256 | test $(grep -c "^tag " output) = 4 && | |
257 | ! grep "Unspecified Tagger" output && | |
258 | git fast-export -C -C --signed-tags=strip --all \ | |
259 | --fake-missing-tagger > output && | |
260 | test $(grep -c "^tag " output) = 4 && | |
261 | grep "Unspecified Tagger" output | |
262 | ||
263 | ' | |
264 | ||
41a5c70f EFL |
265 | test_expect_success 'set-up a few more tags for tag export tests' ' |
266 | git checkout -f master && | |
267 | HEAD_TREE=`git show -s --pretty=raw HEAD | grep tree | sed "s/tree //"` && | |
268 | git tag tree_tag -m "tagging a tree" $HEAD_TREE && | |
269 | git tag -a tree_tag-obj -m "tagging a tree" $HEAD_TREE && | |
270 | git tag tag-obj_tag -m "tagging a tag" tree_tag-obj && | |
271 | git tag -a tag-obj_tag-obj -m "tagging a tag" tree_tag-obj | |
272 | ' | |
273 | ||
274 | # NEEDSWORK: not just check return status, but validate the output | |
c0582c53 EFL |
275 | test_expect_success 'tree_tag' 'git fast-export tree_tag' |
276 | test_expect_success 'tree_tag-obj' 'git fast-export tree_tag-obj' | |
1982467d EFL |
277 | test_expect_success 'tag-obj_tag' 'git fast-export tag-obj_tag' |
278 | test_expect_success 'tag-obj_tag-obj' 'git fast-export tag-obj_tag-obj' | |
41a5c70f | 279 | |
f2dc849e | 280 | test_done |