Handle it successfully if a given parent commit has no parents.
[git-subtree.git] / test.sh
blobdac9b3559af93c633a2c752cbf2efb2bdbfb7c5e
1 #!/bin/bash -x
2 . shellopts.sh
3 set -e
5 rm -rf mainline subproj
6 mkdir mainline subproj
8 cd subproj
9 git init
11 touch sub1
12 git add sub1
13 git commit -m 'sub-1'
14 git branch sub1
15 git branch -m master subproj
17 touch sub2
18 git add sub2
19 git commit -m 'sub-2'
20 git branch sub2
22 touch sub3
23 git add sub3
24 git commit -m 'sub-3'
25 git branch sub3
27 cd ../mainline
28 git init
29 touch main1
30 git add main1
31 git commit -m 'main-1'
32 git branch -m master mainline
34 git fetch ../subproj sub1
35 git branch sub1 FETCH_HEAD
36 git read-tree --prefix=subdir FETCH_HEAD
37 git checkout subdir
38 tree=$(git write-tree)
39 com=$(echo initial-subdir-merge | git commit-tree $tree -p HEAD -p FETCH_HEAD)
40 git reset $com
41 #git commit -m 'initial-subdir-merge'
43 git merge -m 'merge -s -ours' -s ours FETCH_HEAD
45 touch subdir/main-sub3
46 git add subdir/main-sub3
47 git commit -m 'main-sub3'
49 touch main-2
50 git add main-2
51 git commit -m 'main-2 boring'
53 touch subdir/main-sub4
54 git add subdir/main-sub4
55 git commit -m 'main-sub4'
57 git fetch ../subproj sub2
58 git branch sub2 FETCH_HEAD
59 git merge -s subtree FETCH_HEAD
60 git branch pre-split
62 split1=$(git subtree split --prefix subdir --onto FETCH_HEAD --rejoin)
63 echo "split1={$split1}"
64 git branch split1 "$split1"
66 touch subdir/main-sub5
67 git add subdir/main-sub5
68 git commit -m 'main-sub5'
70 cd ../subproj
71 git fetch ../mainline split1
72 git branch split1 FETCH_HEAD
73 git merge FETCH_HEAD
75 touch sub6
76 git add sub6
77 git commit -m 'sub6'
79 cd ../mainline
80 split2=$(git subtree split --prefix subdir --rejoin)
81 git branch split2 "$split2"
83 touch subdir/main-sub7
84 git add subdir/main-sub7
85 git commit -m 'main-sub7'
87 split3=$(git subtree split --prefix subdir --rejoin)
88 git branch split3 "$split3"
90 cd ../subproj
91 git fetch ../mainline split3
92 git branch split3 FETCH_HEAD
93 git merge FETCH_HEAD
94 git branch subproj-merge-split3
96 cd ../mainline
97 git fetch ../subproj subproj-merge-split3
98 git branch subproj-merge-split3 FETCH_HEAD
99 git merge -s subtree subproj-merge-split3