@@ -60,30 +60,26 @@ last_commit_message()
6060 git log --pretty=format:%s -1
6161}
6262
63- # 1
6463test_expect_success ' init subproj' '
6564 test_create_repo subproj
6665'
6766
6867# To the subproject!
6968cd subproj
7069
71- # 2
7270test_expect_success ' add sub1' '
7371 create sub1 &&
7472 git commit -m "sub1" &&
7573 git branch sub1 &&
7674 git branch -m master subproj
7775'
7876
79- # 3
8077test_expect_success ' add sub2' '
8178 create sub2 &&
8279 git commit -m "sub2" &&
8380 git branch sub2
8481'
8582
86- # 4
8783test_expect_success ' add sub3' '
8884 create sub3 &&
8985 git commit -m "sub3" &&
@@ -93,109 +89,92 @@ test_expect_success 'add sub3' '
9389# Back to mainline
9490cd ..
9591
96- # 5
9792test_expect_success ' add main4' '
9893 create main4 &&
9994 git commit -m "main4" &&
10095 git branch -m master mainline &&
10196 git branch subdir
10297'
10398
104- # 6
10599test_expect_success ' fetch subproj history' '
106100 git fetch ./subproj sub1 &&
107101 git branch sub1 FETCH_HEAD
108102'
109103
110- # 7
111104test_expect_success ' no subtree exists in main tree' '
112105 test_must_fail git subtree merge --prefix=subdir sub1
113106'
114107
115- # 8
116108test_expect_success ' no pull from non-existant subtree' '
117109 test_must_fail git subtree pull --prefix=subdir ./subproj sub1
118110'
119111
120- # 9
121112test_expect_success ' check if --message works for add' '
122113 git subtree add --prefix=subdir --message="Added subproject" sub1 &&
123114 check_equal ' ' "$(last_commit_message)"' ' "Added subproject" &&
124115 undo
125116'
126117
127- # 10
128118test_expect_success ' check if --message works as -m and --prefix as -P' '
129119 git subtree add -P subdir -m "Added subproject using git subtree" sub1 &&
130120 check_equal ' ' "$(last_commit_message)"' ' "Added subproject using git subtree" &&
131121 undo
132122'
133123
134- # 11
135124test_expect_success ' check if --message works with squash too' '
136125 git subtree add -P subdir -m "Added subproject with squash" --squash sub1 &&
137126 check_equal ' ' "$(last_commit_message)"' ' "Added subproject with squash" &&
138127 undo
139128'
140129
141- # 12
142130test_expect_success ' add subproj to mainline' '
143131 git subtree add --prefix=subdir/ FETCH_HEAD &&
144132 check_equal ' ' "$(last_commit_message)"' ' "Add ' " 'subdir/'" ' from commit ' " '" ' ' ' "$(git rev-parse sub1)"' ' ' " '" ' "
145133'
146134
147- # 13
148135# this shouldn't actually do anything, since FETCH_HEAD is already a parent
149136test_expect_success ' merge fetched subproj' '
150137 git merge -m "merge -s -ours" -s ours FETCH_HEAD
151138'
152139
153- # 14
154140test_expect_success ' add main-sub5' '
155141 create subdir/main-sub5 &&
156142 git commit -m "main-sub5"
157143'
158144
159- # 15
160145test_expect_success ' add main6' '
161146 create main6 &&
162147 git commit -m "main6 boring"
163148'
164149
165- # 16
166150test_expect_success ' add main-sub7' '
167151 create subdir/main-sub7 &&
168152 git commit -m "main-sub7"
169153'
170154
171- # 17
172155test_expect_success ' fetch new subproj history' '
173156 git fetch ./subproj sub2 &&
174157 git branch sub2 FETCH_HEAD
175158'
176159
177- # 18
178160test_expect_success ' check if --message works for merge' '
179161 git subtree merge --prefix=subdir -m "Merged changes from subproject" sub2 &&
180162 check_equal ' ' "$(last_commit_message)"' ' "Merged changes from subproject" &&
181163 undo
182164'
183165
184- # 19
185166test_expect_success ' check if --message for merge works with squash too' '
186167 git subtree merge --prefix subdir -m "Merged changes from subproject using squash" --squash sub2 &&
187168 check_equal ' ' "$(last_commit_message)"' ' "Merged changes from subproject using squash" &&
188169 undo
189170'
190171
191- # 20
192172test_expect_success ' merge new subproj history into subdir' '
193173 git subtree merge --prefix=subdir FETCH_HEAD &&
194174 git branch pre-split &&
195175 check_equal ' ' "$(last_commit_message)"' ' "Merge commit ' " '" ' "$(git rev-parse sub2)"' " '" ' into mainline"
196176'
197177
198- # 21
199178test_expect_success ' Check that prefix argument is required for split' '
200179 echo "You must provide the --prefix option." > expected &&
201180 test_must_fail git subtree split > actual 2>&1 &&
@@ -207,7 +186,6 @@ test_expect_success 'Check that prefix argument is required for split' '
207186 rm -f expected actual
208187'
209188
210- # 22
211189test_expect_success ' Check that the <prefix> exists for a split' '
212190 echo "' " '" ' non-existent-directory' " '" ' " does not exist\; use "' " '" ' git subtree add' " '" ' " > expected &&
213191 test_must_fail git subtree split --prefix=non-existent-directory > actual 2>&1 &&
@@ -219,23 +197,20 @@ test_expect_success 'Check that the <prefix> exists for a split' '
219197# rm -f expected actual
220198'
221199
222- # 23
223200test_expect_success ' check if --message works for split+rejoin' '
224201 spl1=' ' "$(git subtree split --annotate=' " '*'" ' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin)"' ' &&
225202 git branch spl1 "$spl1" &&
226203 check_equal ' ' "$(last_commit_message)"' ' "Split & rejoin" &&
227204 undo
228205'
229206
230- # 24
231207test_expect_success ' check split with --branch' '
232208 spl1=$(git subtree split --annotate=' " '*'" ' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin) &&
233209 undo &&
234210 git subtree split --annotate=' " '*'" ' --prefix subdir --onto FETCH_HEAD --branch splitbr1 &&
235211 check_equal ' ' "$(git rev-parse splitbr1)"' ' "$spl1"
236212'
237213
238- # 25
239214test_expect_success ' check split with --branch for an existing branch' '
240215 spl1=' ' "$(git subtree split --annotate=' " '*'" ' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin)"' ' &&
241216 undo &&
@@ -244,21 +219,17 @@ test_expect_success 'check split with --branch for an existing branch' '
244219 check_equal ' ' "$(git rev-parse splitbr2)"' ' "$spl1"
245220'
246221
247- # 26
248222test_expect_success ' check split with --branch for an incompatible branch' '
249223 test_must_fail git subtree split --prefix subdir --onto FETCH_HEAD --branch subdir
250224'
251225
252-
253- # 27
254226test_expect_success ' check split+rejoin' '
255227 spl1=' ' "$(git subtree split --annotate=' " '*'" ' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin)"' ' &&
256228 undo &&
257229 git subtree split --annotate=' " '*'" ' --prefix subdir --onto FETCH_HEAD --rejoin &&
258230 check_equal ' ' "$(last_commit_message)"' ' "Split ' " '" ' subdir/' " '" ' into commit ' " '" ' "$spl1"' " '" ' "
259231'
260232
261- # 28
262233test_expect_success ' add main-sub8' '
263234 create subdir/main-sub8 &&
264235 git commit -m "main-sub8"
@@ -267,14 +238,12 @@ test_expect_success 'add main-sub8' '
267238# To the subproject!
268239cd ./subproj
269240
270- # 29
271241test_expect_success ' merge split into subproj' '
272242 git fetch .. spl1 &&
273243 git branch spl1 FETCH_HEAD &&
274244 git merge FETCH_HEAD
275245'
276246
277- # 30
278247test_expect_success ' add sub9' '
279248 create sub9 &&
280249 git commit -m "sub9"
@@ -283,19 +252,16 @@ test_expect_success 'add sub9' '
283252# Back to mainline
284253cd ..
285254
286- # 31
287255test_expect_success ' split for sub8' '
288256 split2=' ' "$(git subtree split --annotate=' " '*'" ' --prefix subdir/ --rejoin)"' '
289257 git branch split2 "$split2"
290258'
291259
292- # 32
293260test_expect_success ' add main-sub10' '
294261 create subdir/main-sub10 &&
295262 git commit -m "main-sub10"
296263'
297264
298- # 33
299265test_expect_success ' split for sub10' '
300266 spl3=' ' "$(git subtree split --annotate=' " '*'" ' --prefix subdir --rejoin)"' ' &&
301267 git branch spl3 "$spl3"
@@ -304,7 +270,6 @@ test_expect_success 'split for sub10' '
304270# To the subproject!
305271cd ./subproj
306272
307- # 34
308273test_expect_success ' merge split into subproj' '
309274 git fetch .. spl3 &&
310275 git branch spl3 FETCH_HEAD &&
@@ -318,13 +283,11 @@ chkms_sub=$(echo $chkms | multiline | sed 's,^,subdir/,' | fixnl)
318283chks=" sub1 sub2 sub3 sub9"
319284chks_sub=$( echo $chks | multiline | sed ' s,^,subdir/,' | fixnl)
320285
321- # 35
322286test_expect_success ' make sure exactly the right set of files ends up in the subproj' '
323287 subfiles=' ' "$(git ls-files | fixnl)"' ' &&
324288 check_equal "$subfiles" "$chkms $chks"
325289'
326290
327- # 36
328291test_expect_success ' make sure the subproj history *only* contains commits that affect the subdir' '
329292 allchanges=' ' "$(git log --name-only --pretty=format:' " ''" ' | sort | fixnl)"' ' &&
330293 check_equal "$allchanges" "$chkms $chks"
@@ -333,20 +296,17 @@ test_expect_success 'make sure the subproj history *only* contains commits that
333296# Back to mainline
334297cd ..
335298
336- # 37
337299test_expect_success ' pull from subproj' '
338300 git fetch ./subproj subproj-merge-spl3 &&
339301 git branch subproj-merge-spl3 FETCH_HEAD &&
340302 git subtree pull --prefix=subdir ./subproj subproj-merge-spl3
341303'
342304
343- # 38
344305test_expect_success ' make sure exactly the right set of files ends up in the mainline' '
345306 mainfiles=' ' "$(git ls-files | fixnl)"' ' &&
346307 check_equal "$mainfiles" "$chkm $chkms_sub $chks_sub"
347308'
348309
349- # 39
350310test_expect_success ' make sure each filename changed exactly once in the entire history' '
351311 # main-sub?? and /subdir/main-sub?? both change, because those are the
352312 # changes that were split into their own history. And subdir/sub?? never
@@ -355,12 +315,10 @@ test_expect_success 'make sure each filename changed exactly once in the entire
355315 check_equal "$allchanges" ' ' "$(echo $chkms $chkm $chks $chkms_sub | multiline | sort | fixnl)"' '
356316'
357317
358- # 40
359318test_expect_success ' make sure the --rejoin commits never make it into subproj' '
360319 check_equal ' ' "$(git log --pretty=format:' " '%s'" ' HEAD^2 | grep -i split)"' ' ""
361320'
362321
363- # 41
364322test_expect_success ' make sure no "git subtree" tagged commits make it into subproj' '
365323 # They are meaningless to subproj since one side of the merge refers to the mainline
366324 check_equal ' ' "$(git log --pretty=format:' " '%s%n%b'" ' HEAD^2 | grep "git-subtree.*:")"' ' ""
@@ -370,29 +328,25 @@ test_expect_success 'make sure no "git subtree" tagged commits make it into subp
370328mkdir test2
371329cd test2
372330
373- # 42
374331test_expect_success ' init main' '
375332 test_create_repo main
376333'
377334
378335cd main
379336
380- # 43
381337test_expect_success ' add main1' '
382338 create main1 &&
383339 git commit -m "main1"
384340'
385341
386342cd ..
387343
388- # 44
389344test_expect_success ' init sub' '
390345 test_create_repo sub
391346'
392347
393348cd sub
394349
395- # 45
396350test_expect_success ' add sub2' '
397351 create sub2 &&
398352 git commit -m "sub2"
@@ -402,7 +356,6 @@ cd ../main
402356
403357# check if split can find proper base without --onto
404358
405- # 46
406359test_expect_success ' add sub as subdir in main' '
407360 git fetch ../sub master &&
408361 git branch sub2 FETCH_HEAD &&
@@ -411,28 +364,24 @@ test_expect_success 'add sub as subdir in main' '
411364
412365cd ../sub
413366
414- # 47
415367test_expect_success ' add sub3' '
416368 create sub3 &&
417369 git commit -m "sub3"
418370'
419371
420372cd ../main
421373
422- # 48
423374test_expect_success ' merge from sub' '
424375 git fetch ../sub master &&
425376 git branch sub3 FETCH_HEAD &&
426377 git subtree merge --prefix subdir sub3
427378'
428379
429- # 49
430380test_expect_success ' add main-sub4' '
431381 create subdir/main-sub4 &&
432382 git commit -m "main-sub4"
433383'
434384
435- # 50
436385test_expect_success ' split for main-sub4 without --onto' '
437386 git subtree split --prefix subdir --branch mainsub4
438387'
@@ -442,19 +391,16 @@ test_expect_success 'split for main-sub4 without --onto' '
442391# have been sub3, but it was not, because its cache was not set to
443392# itself)
444393
445- # 51
446394test_expect_success ' check that the commit parent is sub3' '
447395 check_equal ' ' "$(git log --pretty=format:%P -1 mainsub4)"' ' ' ' "$(git rev-parse sub3)"' '
448396'
449397
450- # 52
451398test_expect_success ' add main-sub5' '
452399 mkdir subdir2 &&
453400 create subdir2/main-sub5 &&
454401 git commit -m "main-sub5"
455402'
456403
457- # 53
458404test_expect_success ' split for main-sub5 without --onto' '
459405 # also test that we still can split out an entirely new subtree
460406 # if the parent of the first commit in the tree is not empty,
@@ -487,7 +433,6 @@ joincommits()
487433 echo " $commit $all "
488434}
489435
490- # 54
491436test_expect_success ' verify one file change per commit' '
492437 x= &&
493438 list=' ' "$(git log --pretty=format:' " 'commit: %H'" ' | joincommits)"' ' &&
0 commit comments