Use Test Harness

Clean up the git-subtree tests to conform the git project conventions and use the existing test harness. Signed-off-by: David A. Greene <greened@obbligato.org>

David A. Greene committed Jan 29, 2012 at 16:09 UTC d3a04e06c77d57978bb5230361c64946232cc346
1 file changed +405 -241
t/t7900-subtree.sh
+405 -241
@@ -1,6 +1,14 @@
1 -#!/bin/bash
2 -. shellopts.sh
3 -set -e
1 +#!/bin/sh
2 +#
3 +# Copyright (c) 2012 Avery Pennaraum
4 +#
5 +test_description='Basic porcelain support for subtrees
6 +
7 +This test verifies the basic operation of the merge, pull, add
8 +and split subcommands of git subtree.
9 +'
10 +
11 +. ./test-lib.sh
12
13 create()
14 {
@@ -8,42 +16,16 @@ create()
16 git add "$1"
17 }
18
11 -check()
12 -{
13 - echo
14 - echo "check:" "$@"
15 - if "$@"; then
16 - echo ok
17 - return 0
18 - else
19 - echo FAILED
20 - exit 1
21 - fi
22 -}
23 -
24 -check_not()
25 -{
26 - echo
27 - echo "check: NOT " "$@"
28 - if "$@"; then
29 - echo FAILED
30 - exit 1
31 - else
32 - echo ok
33 - return 0
34 - fi
35 -}
19
20 check_equal()
21 {
39 - echo
40 - echo "check a:" "{$1}"
41 - echo " b:" "{$2}"
22 + test_debug 'echo'
23 + test_debug "echo \"check a:\" \"{$1}\""
24 + test_debug "echo \" b:\" \"{$2}\""
25 if [ "$1" = "$2" ]; then
26 return 0
27 else
45 - echo FAILED
46 - exit 1
28 + return 1
29 fi
30 }
31
@@ -76,144 +58,257 @@ last_commit_message()
58 git log --pretty=format:%s -1
59 }
60
79 -rm -rf mainline subproj
80 -mkdir mainline subproj
61 +# 1
62 +test_expect_success 'init subproj' '
63 + test_create_repo subproj
64 +'
65
66 +# To the subproject!
67 cd subproj
83 -git init
84 -
85 -create sub1
86 -git commit -m 'sub1'
87 -git branch sub1
88 -git branch -m master subproj
89 -check true
90 -
91 -create sub2
92 -git commit -m 'sub2'
93 -git branch sub2
94 -
95 -create sub3
96 -git commit -m 'sub3'
97 -git branch sub3
98 -
99 -cd ../mainline
100 -git init
101 -create main4
102 -git commit -m 'main4'
103 -git branch -m master mainline
104 -git branch subdir
105 -
106 -git fetch ../subproj sub1
107 -git branch sub1 FETCH_HEAD
108 -
109 -# check if --message works for add
110 -check_not git subtree merge --prefix=subdir sub1
111 -check_not git subtree pull --prefix=subdir ../subproj sub1
112 -git subtree add --prefix=subdir --message="Added subproject" sub1
113 -check_equal "$(last_commit_message)" "Added subproject"
114 -undo
115 -
116 -# check if --message works as -m and --prefix as -P
117 -git subtree add -P subdir -m "Added subproject using git subtree" sub1
118 -check_equal "$(last_commit_message)" "Added subproject using git subtree"
119 -undo
120 -
121 -# check if --message works with squash too
122 -git subtree add -P subdir -m "Added subproject with squash" --squash sub1
123 -check_equal "$(last_commit_message)" "Added subproject with squash"
124 -undo
125 -
126 -git subtree add --prefix=subdir/ FETCH_HEAD
127 -check_equal "$(last_commit_message)" "Add 'subdir/' from commit '$(git rev-parse sub1)'"
128 -
129 -# this shouldn't actually do anything, since FETCH_HEAD is already a parent
130 -git merge -m 'merge -s -ours' -s ours FETCH_HEAD
131 -
132 -create subdir/main-sub5
133 -git commit -m 'main-sub5'
134 -
135 -create main6
136 -git commit -m 'main6 boring'
137 -
138 -create subdir/main-sub7
139 -git commit -m 'main-sub7'
140 -
141 -git fetch ../subproj sub2
142 -git branch sub2 FETCH_HEAD
143 -
144 -# check if --message works for merge
145 -git subtree merge --prefix=subdir -m "Merged changes from subproject" sub2
146 -check_equal "$(last_commit_message)" "Merged changes from subproject"
147 -undo
148 -
149 -# check if --message for merge works with squash too
150 -git subtree merge --prefix subdir -m "Merged changes from subproject using squash" --squash sub2
151 -check_equal "$(last_commit_message)" "Merged changes from subproject using squash"
152 -undo
153 -
154 -git subtree merge --prefix=subdir FETCH_HEAD
155 -git branch pre-split
156 -check_equal "$(last_commit_message)" "Merge commit '$(git rev-parse sub2)' into mainline"
157 -
158 -# Check that prefix argument is required for split (exits with warning and exit status = 1)
159 -! result=$(git subtree split 2>&1)
160 -check_equal "You must provide the --prefix option." "$result"
161 -
162 -# Check that the <prefix> exists for a split.
163 -! result=$(git subtree split --prefix=non-existent-directory 2>&1)
164 -check_equal "'non-existent-directory' does not exist; use 'git subtree add'" \
165 - "$result"
166 -
167 -# check if --message works for split+rejoin
168 -spl1=$(git subtree split --annotate='*' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin)
169 -echo "spl1={$spl1}"
170 -git branch spl1 "$spl1"
171 -check_equal "$(last_commit_message)" "Split & rejoin"
172 -undo
173 -
174 -# check split with --branch
175 -git subtree split --annotate='*' --prefix subdir --onto FETCH_HEAD --branch splitbr1
176 -check_equal "$(git rev-parse splitbr1)" "$spl1"
177 -
178 -# check split with --branch for an existing branch
179 -git branch splitbr2 sub1
180 -git subtree split --annotate='*' --prefix subdir --onto FETCH_HEAD --branch splitbr2
181 -check_equal "$(git rev-parse splitbr2)" "$spl1"
182 -
183 -# check split with --branch for an incompatible branch
184 -result=$(git subtree split --prefix subdir --onto FETCH_HEAD --branch subdir || echo "caught error")
185 -check_equal "$result" "caught error"
68
69 +# 2
70 +test_expect_success 'add sub1' '
71 + create sub1 &&
72 + git commit -m "sub1" &&
73 + git branch sub1 &&
74 + git branch -m master subproj
75 +'
76 +
77 +# 3
78 +test_expect_success 'add sub2' '
79 + create sub2 &&
80 + git commit -m "sub2" &&
81 + git branch sub2
82 +'
83 +
84 +# 4
85 +test_expect_success 'add sub3' '
86 + create sub3 &&
87 + git commit -m "sub3" &&
88 + git branch sub3
89 +'
90 +
91 +# Back to mainline
92 +cd ..
93
188 -git subtree split --annotate='*' --prefix subdir --onto FETCH_HEAD --rejoin
189 -check_equal "$(last_commit_message)" "Split 'subdir/' into commit '$spl1'"
190 -
191 -create subdir/main-sub8
192 -git commit -m 'main-sub8'
193 -
194 -cd ../subproj
195 -git fetch ../mainline spl1
196 -git branch spl1 FETCH_HEAD
197 -git merge FETCH_HEAD
198 -
199 -create sub9
200 -git commit -m 'sub9'
201 -
202 -cd ../mainline
203 -split2=$(git subtree split --annotate='*' --prefix subdir/ --rejoin)
204 -git branch split2 "$split2"
205 -
206 -create subdir/main-sub10
207 -git commit -m 'main-sub10'
208 -
209 -spl3=$(git subtree split --annotate='*' --prefix subdir --rejoin)
210 -git branch spl3 "$spl3"
94 +# 5
95 +test_expect_success 'add main4' '
96 + create main4 &&
97 + git commit -m "main4" &&
98 + git branch -m master mainline &&
99 + git branch subdir
100 +'
101 +
102 +# 6
103 +test_expect_success 'fetch subproj history' '
104 + git fetch ./subproj sub1 &&
105 + git branch sub1 FETCH_HEAD
106 +'
107 +
108 +# 7
109 +test_expect_success 'no subtree exists in main tree' '
110 + test_must_fail git subtree merge --prefix=subdir sub1
111 +'
112 +
113 +# 8
114 +test_expect_success 'no pull from non-existant subtree' '
115 + test_must_fail git subtree pull --prefix=subdir ./subproj sub1
116 +'
117 +
118 +# 9
119 +test_expect_success 'check if --message works for add' '
120 + git subtree add --prefix=subdir --message="Added subproject" sub1 &&
121 + check_equal ''"$(last_commit_message)"'' "Added subproject" &&
122 + undo
123 +'
124 +
125 +# 10
126 +test_expect_success 'check if --message works as -m and --prefix as -P' '
127 + git subtree add -P subdir -m "Added subproject using git subtree" sub1 &&
128 + check_equal ''"$(last_commit_message)"'' "Added subproject using git subtree" &&
129 + undo
130 +'
131 +
132 +# 11
133 +test_expect_success 'check if --message works with squash too' '
134 + git subtree add -P subdir -m "Added subproject with squash" --squash sub1 &&
135 + check_equal ''"$(last_commit_message)"'' "Added subproject with squash" &&
136 + undo
137 +'
138 +
139 +# 12
140 +test_expect_success 'add subproj to mainline' '
141 + git subtree add --prefix=subdir/ FETCH_HEAD &&
142 + check_equal ''"$(last_commit_message)"'' "Add '"'subdir/'"' from commit '"'"'''"$(git rev-parse sub1)"'''"'"'"
143 +'
144 +
145 +# 13
146 +# this shouldn't actually do anything, since FETCH_HEAD is already a parent
147 +test_expect_success 'merge fetched subproj' '
148 + git merge -m "merge -s -ours" -s ours FETCH_HEAD
149 +'
150 +
151 +# 14
152 +test_expect_success 'add main-sub5' '
153 + create subdir/main-sub5 &&
154 + git commit -m "main-sub5"
155 +'
156 +
157 +# 15
158 +test_expect_success 'add main6' '
159 + create main6 &&
160 + git commit -m "main6 boring"
161 +'
162 +
163 +# 16
164 +test_expect_success 'add main-sub7' '
165 + create subdir/main-sub7 &&
166 + git commit -m "main-sub7"
167 +'
168 +
169 +# 17
170 +test_expect_success 'fetch new subproj history' '
171 + git fetch ./subproj sub2 &&
172 + git branch sub2 FETCH_HEAD
173 +'
174 +
175 +# 18
176 +test_expect_success 'check if --message works for merge' '
177 + git subtree merge --prefix=subdir -m "Merged changes from subproject" sub2 &&
178 + check_equal ''"$(last_commit_message)"'' "Merged changes from subproject" &&
179 + undo
180 +'
181 +
182 +# 19
183 +test_expect_success 'check if --message for merge works with squash too' '
184 + git subtree merge --prefix subdir -m "Merged changes from subproject using squash" --squash sub2 &&
185 + check_equal ''"$(last_commit_message)"'' "Merged changes from subproject using squash" &&
186 + undo
187 +'
188 +
189 +# 20
190 +test_expect_success 'merge new subproj history into subdir' '
191 + git subtree merge --prefix=subdir FETCH_HEAD &&
192 + git branch pre-split &&
193 + check_equal ''"$(last_commit_message)"'' "Merge commit '"'"'"$(git rev-parse sub2)"'"'"' into mainline"
194 +'
195 +
196 +# 21
197 +test_expect_success 'Check that prefix argument is required for split' '
198 + echo "You must provide the --prefix option." > expected &&
199 + test_must_fail git subtree split > actual 2>&1 &&
200 + test_debug "echo -n expected: " &&
201 + test_debug "cat expected" &&
202 + test_debug "echo -n actual: " &&
203 + test_debug "cat actual" &&
204 + test_cmp expected actual &&
205 + rm -f expected actual
206 +'
207 +
208 +# 22
209 +test_expect_success 'Check that the <prefix> exists for a split' '
210 + echo "'"'"'non-existent-directory'"'"'" does not exist\; use "'"'"'git subtree add'"'"'" > expected &&
211 + test_must_fail git subtree split --prefix=non-existent-directory > actual 2>&1 &&
212 + test_debug "echo -n expected: " &&
213 + test_debug "cat expected" &&
214 + test_debug "echo -n actual: " &&
215 + test_debug "cat actual" &&
216 + test_cmp expected actual
217 +# rm -f expected actual
218 +'
219 +
220 +# 23
221 +test_expect_success 'check if --message works for split+rejoin' '
222 + spl1=''"$(git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin)"'' &&
223 + git branch spl1 "$spl1" &&
224 + check_equal ''"$(last_commit_message)"'' "Split & rejoin" &&
225 + undo
226 +'
227 +
228 +# 24
229 +test_expect_success 'check split with --branch' '
230 + spl1=$(git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin) &&
231 + undo &&
232 + git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --branch splitbr1 &&
233 + check_equal ''"$(git rev-parse splitbr1)"'' "$spl1"
234 +'
235 +
236 +# 25
237 +test_expect_success 'check split with --branch for an existing branch' '
238 + spl1=''"$(git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin)"'' &&
239 + undo &&
240 + git branch splitbr2 sub1 &&
241 + git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --branch splitbr2 &&
242 + check_equal ''"$(git rev-parse splitbr2)"'' "$spl1"
243 +'
244 +
245 +# 26
246 +test_expect_success 'check split with --branch for an incompatible branch' '
247 + test_must_fail git subtree split --prefix subdir --onto FETCH_HEAD --branch subdir
248 +'
249 +
250 +
251 +# 27
252 +test_expect_success 'check split+rejoin' '
253 + spl1=''"$(git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin)"'' &&
254 + undo &&
255 + git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --rejoin &&
256 + check_equal ''"$(last_commit_message)"'' "Split '"'"'subdir/'"'"' into commit '"'"'"$spl1"'"'"'"
257 +'
258 +
259 +# 28
260 +test_expect_success 'add main-sub8' '
261 + create subdir/main-sub8 &&
262 + git commit -m "main-sub8"
263 +'
264 +
265 +# To the subproject!
266 +cd ./subproj
267 +
268 +# 29
269 +test_expect_success 'merge split into subproj' '
270 + git fetch .. spl1 &&
271 + git branch spl1 FETCH_HEAD &&
272 + git merge FETCH_HEAD
273 +'
274 +
275 +# 30
276 +test_expect_success 'add sub9' '
277 + create sub9 &&
278 + git commit -m "sub9"
279 +'
280 +
281 +# Back to mainline
282 +cd ..
283
212 -cd ../subproj
213 -git fetch ../mainline spl3
214 -git branch spl3 FETCH_HEAD
215 -git merge FETCH_HEAD
216 -git branch subproj-merge-spl3
284 +# 31
285 +test_expect_success 'split for sub8' '
286 + split2=''"$(git subtree split --annotate='"'*'"' --prefix subdir/ --rejoin)"''
287 + git branch split2 "$split2"
288 +'
289 +
290 +# 32
291 +test_expect_success 'add main-sub10' '
292 + create subdir/main-sub10 &&
293 + git commit -m "main-sub10"
294 +'
295 +
296 +# 33
297 +test_expect_success 'split for sub10' '
298 + spl3=''"$(git subtree split --annotate='"'*'"' --prefix subdir --rejoin)"'' &&
299 + git branch spl3 "$spl3"
300 +'
301 +
302 +# To the subproject!
303 +cd ./subproj
304 +
305 +# 34
306 +test_expect_success 'merge split into subproj' '
307 + git fetch .. spl3 &&
308 + git branch spl3 FETCH_HEAD &&
309 + git merge FETCH_HEAD &&
310 + git branch subproj-merge-spl3
311 +'
312
313 chkm="main4 main6"
314 chkms="main-sub10 main-sub5 main-sub7 main-sub8"
@@ -221,89 +316,150 @@ chkms_sub=$(echo $chkms | multiline | sed 's,^,subdir/,' | fixnl)
316 chks="sub1 sub2 sub3 sub9"
317 chks_sub=$(echo $chks | multiline | sed 's,^,subdir/,' | fixnl)
318
224 -# make sure exactly the right set of files ends up in the subproj
225 -subfiles=$(git ls-files | fixnl)
226 -check_equal "$subfiles" "$chkms $chks"
227 -
228 -# make sure the subproj history *only* contains commits that affect the subdir.
229 -allchanges=$(git log --name-only --pretty=format:'' | sort | fixnl)
230 -check_equal "$allchanges" "$chkms $chks"
231 -
232 -cd ../mainline
233 -git fetch ../subproj subproj-merge-spl3
234 -git branch subproj-merge-spl3 FETCH_HEAD
235 -git subtree pull --prefix=subdir ../subproj subproj-merge-spl3
319 +# 35
320 +test_expect_success 'make sure exactly the right set of files ends up in the subproj' '
321 + subfiles=''"$(git ls-files | fixnl)"'' &&
322 + check_equal "$subfiles" "$chkms $chks"
323 +'
324
237 -# make sure exactly the right set of files ends up in the mainline
238 -mainfiles=$(git ls-files | fixnl)
239 -check_equal "$mainfiles" "$chkm $chkms_sub $chks_sub"
325 +# 36
326 +test_expect_success 'make sure the subproj history *only* contains commits that affect the subdir' '
327 + allchanges=''"$(git log --name-only --pretty=format:'"''"' | sort | fixnl)"'' &&
328 + check_equal "$allchanges" "$chkms $chks"
329 +'
330
241 -# make sure each filename changed exactly once in the entire history.
242 -# 'main-sub??' and '/subdir/main-sub??' both change, because those are the
243 -# changes that were split into their own history. And 'subdir/sub??' never
244 -# change, since they were *only* changed in the subtree branch.
245 -allchanges=$(git log --name-only --pretty=format:'' | sort | fixnl)
246 -check_equal "$allchanges" "$(echo $chkms $chkm $chks $chkms_sub | multiline | sort | fixnl)"
247 -
248 -# make sure the --rejoin commits never make it into subproj
249 -check_equal "$(git log --pretty=format:'%s' HEAD^2 | grep -i split)" ""
250 -
251 -# make sure no 'git subtree' tagged commits make it into subproj. (They're
252 -# meaningless to subproj since one side of the merge refers to the mainline)
253 -check_equal "$(git log --pretty=format:'%s%n%b' HEAD^2 | grep 'git-subtree.*:')" ""
331 +# Back to mainline
332 +cd ..
333
334 +# 37
335 +test_expect_success 'pull from subproj' '
336 + git fetch ./subproj subproj-merge-spl3 &&
337 + git branch subproj-merge-spl3 FETCH_HEAD &&
338 + git subtree pull --prefix=subdir ./subproj subproj-merge-spl3
339 +'
340 +
341 +# 38
342 +test_expect_success 'make sure exactly the right set of files ends up in the mainline' '
343 + mainfiles=''"$(git ls-files | fixnl)"'' &&
344 + check_equal "$mainfiles" "$chkm $chkms_sub $chks_sub"
345 +'
346 +
347 +# 39
348 +test_expect_success 'make sure each filename changed exactly once in the entire history' '
349 + # main-sub?? and /subdir/main-sub?? both change, because those are the
350 + # changes that were split into their own history. And subdir/sub?? never
351 + # change, since they were *only* changed in the subtree branch.
352 + allchanges=''"$(git log --name-only --pretty=format:'"''"' | sort | fixnl)"'' &&
353 + check_equal "$allchanges" ''"$(echo $chkms $chkm $chks $chkms_sub | multiline | sort | fixnl)"''
354 +'
355 +
356 +# 40
357 +test_expect_success 'make sure the --rejoin commits never make it into subproj' '
358 + check_equal ''"$(git log --pretty=format:'"'%s'"' HEAD^2 | grep -i split)"'' ""
359 +'
360 +
361 +# 41
362 +test_expect_success 'make sure no "git subtree" tagged commits make it into subproj' '
363 + # They are meaningless to subproj since one side of the merge refers to the mainline
364 + check_equal ''"$(git log --pretty=format:'"'%s%n%b'"' HEAD^2 | grep "git-subtree.*:")"'' ""
365 +'
366
256 -# check if split can find proper base without --onto
367 # prepare second pair of repositories
368 mkdir test2
369 cd test2
370
261 -mkdir main
371 +# 42
372 +test_expect_success 'init main' '
373 + test_create_repo main
374 +'
375 +
376 cd main
263 -git init
264 -create main1
265 -git commit -m "main1"
377 +
378 +# 43
379 +test_expect_success 'add main1' '
380 + create main1 &&
381 + git commit -m "main1"
382 +'
383
384 cd ..
268 -mkdir sub
269 -cd sub
270 -git init
271 -create sub2
272 -git commit -m "sub2"
385
274 -cd ../main
275 -git fetch ../sub master
276 -git branch sub2 FETCH_HEAD
277 -git subtree add --prefix subdir sub2
386 +# 44
387 +test_expect_success 'init sub' '
388 + test_create_repo sub
389 +'
390
279 -cd ../sub
280 -create sub3
281 -git commit -m "sub3"
391 +cd sub
392 +
393 +# 45
394 +test_expect_success 'add sub2' '
395 + create sub2 &&
396 + git commit -m "sub2"
397 +'
398
399 cd ../main
284 -git fetch ../sub master
285 -git branch sub3 FETCH_HEAD
286 -git subtree merge --prefix subdir sub3
400
288 -create subdir/main-sub4
289 -git commit -m "main-sub4"
290 -git subtree split --prefix subdir --branch mainsub4
401 +# check if split can find proper base without --onto
402 +
403 +# 46
404 +test_expect_success 'add sub as subdir in main' '
405 + git fetch ../sub master &&
406 + git branch sub2 FETCH_HEAD &&
407 + git subtree add --prefix subdir sub2
408 +'
409
292 -# at this point, the new commit's parent should be sub3
293 -# if it's not, something went wrong (the "newparent" of "master~" commit should have been sub3,
294 -# but it wasn't, because it's cache was not set to itself)
295 -check_equal "$(git log --pretty=format:%P -1 mainsub4)" "$(git rev-parse sub3)"
410 +cd ../sub
411
297 -mkdir subdir2
298 -create subdir2/main-sub5
299 -git commit -m "main-sub5"
300 -git subtree split --prefix subdir2 --branch mainsub5
412 +# 47
413 +test_expect_success 'add sub3' '
414 + create sub3 &&
415 + git commit -m "sub3"
416 +'
417
302 -# also test that we still can split out an entirely new subtree
303 -# if the parent of the first commit in the tree isn't empty,
304 -# then the new subtree has accidently been attached to something
305 -check_equal "$(git log --pretty=format:%P -1 mainsub5)" ""
418 +cd ../main
419
420 +# 48
421 +test_expect_success 'merge from sub' '
422 + git fetch ../sub master &&
423 + git branch sub3 FETCH_HEAD &&
424 + git subtree merge --prefix subdir sub3
425 +'
426 +
427 +# 49
428 +test_expect_success 'add main-sub4' '
429 + create subdir/main-sub4 &&
430 + git commit -m "main-sub4"
431 +'
432 +
433 +# 50
434 +test_expect_success 'split for main-sub4 without --onto' '
435 + git subtree split --prefix subdir --branch mainsub4
436 +'
437 +
438 +# at this point, the new commit parent should be sub3 if it is not,
439 +# something went wrong (the "newparent" of "master~" commit should
440 +# have been sub3, but it was not, because its cache was not set to
441 +# itself)
442 +
443 +# 51
444 +test_expect_success 'check that the commit parent is sub3' '
445 + check_equal ''"$(git log --pretty=format:%P -1 mainsub4)"'' ''"$(git rev-parse sub3)"''
446 +'
447 +
448 +# 52
449 +test_expect_success 'add main-sub5' '
450 + mkdir subdir2 &&
451 + create subdir2/main-sub5 &&
452 + git commit -m "main-sub5"
453 +'
454 +
455 +# 53
456 +test_expect_success 'split for main-sub5 without --onto' '
457 + # also test that we still can split out an entirely new subtree
458 + # if the parent of the first commit in the tree is not empty,
459 + # then the new subtree has accidently been attached to something
460 + git subtree split --prefix subdir2 --branch mainsub5 &&
461 + check_equal ''"$(git log --pretty=format:%P -1 mainsub5)"'' ""
462 +'
463
464 # make sure no patch changes more than one file. The original set of commits
465 # changed only one file each. A multi-file change would imply that we pruned
@@ -313,7 +469,7 @@ joincommits()
469 commit=
470 all=
471 while read x y; do
316 - echo "{$x}" >&2
472 + #echo "{$x}" >&2
473 if [ -z "$x" ]; then
474 continue
475 elif [ "$x" = "commit:" ]; then
@@ -328,15 +484,23 @@ joincommits()
484 done
485 echo "$commit $all"
486 }
331 -x=
332 -git log --pretty=format:'commit: %H' | joincommits |
333 -( while read commit a b; do
334 - echo "Verifying commit $commit"
335 - check_equal "$b" ""
336 - x=1
337 - done
338 - check_equal "$x" 1
339 -) || exit 1
487
341 -echo
342 -echo 'ok'
488 +# 54
489 +test_expect_success 'verify one file change per commit' '
490 + x= &&
491 + list=''"$(git log --pretty=format:'"'commit: %H'"' | joincommits)"'' &&
492 +# test_debug "echo HERE" &&
493 +# test_debug "echo ''"$list"''" &&
494 + (git log --pretty=format:'"'commit: %H'"' | joincommits |
495 + ( while read commit a b; do
496 + test_debug "echo Verifying commit "''"$commit"''
497 + test_debug "echo a: "''"$a"''
498 + test_debug "echo b: "''"$b"''
499 + check_equal "$b" ""
500 + x=1
501 + done
502 + check_equal "$x" 1
503 + ))
504 +'
505 +
506 +test_done