27 echo "check a:" "{$1}"
29 if [ "$1" = "$2" ]; then
56 rm -rf mainline subproj
57 mkdir mainline subproj
65 git branch
-m master subproj
80 git branch
-m master mainline
82 git fetch ..
/subproj sub1
83 git branch sub1 FETCH_HEAD
84 git subtree add
--prefix=subdir FETCH_HEAD
86 # this shouldn't actually do anything, since FETCH_HEAD is already a parent
87 git merge
-m 'merge -s -ours' -s ours FETCH_HEAD
89 create subdir
/main-sub5
90 git commit
-m 'main-sub5'
93 git commit
-m 'main6 boring'
95 create subdir
/main-sub7
96 git commit
-m 'main-sub7'
98 git fetch ..
/subproj sub2
99 git branch sub2 FETCH_HEAD
100 git subtree merge
--prefix=subdir FETCH_HEAD
103 spl1
=$
(git subtree
split --annotate='*' \
104 --prefix subdir
--onto FETCH_HEAD
--rejoin)
106 git branch spl1
"$spl1"
108 create subdir
/main-sub8
109 git commit
-m 'main-sub8'
112 git fetch ..
/mainline spl1
113 git branch spl1 FETCH_HEAD
120 split2
=$
(git subtree
split --annotate='*' --prefix subdir
--rejoin)
121 git branch split2
"$split2"
123 create subdir
/main-sub10
124 git commit
-m 'main-sub10'
126 spl3
=$
(git subtree
split --annotate='*' --prefix subdir
--rejoin)
127 git branch spl3
"$spl3"
130 git fetch ..
/mainline spl3
131 git branch spl3 FETCH_HEAD
133 git branch subproj-merge-spl3
136 chkms
="main-sub10 main-sub5 main-sub7 main-sub8"
137 chkms_sub
=$
(echo $chkms | multiline |
sed 's,^,subdir/,' | fixnl
)
138 chks
="sub1 sub2 sub3 sub9"
139 chks_sub
=$
(echo $chks | multiline |
sed 's,^,subdir/,' | fixnl
)
141 # make sure exactly the right set of files ends up in the subproj
142 subfiles
=$
(git ls-files | fixnl
)
143 check_equal
"$subfiles" "$chkms $chks"
145 # make sure the subproj history *only* contains commits that affect the subdir.
146 allchanges
=$
(git log
--name-only --pretty=format
:'' |
sort | fixnl
)
147 check_equal
"$allchanges" "$chkms $chks"
150 git fetch ..
/subproj subproj-merge-spl3
151 git branch subproj-merge-spl3 FETCH_HEAD
152 git subtree pull
--prefix=subdir ..
/subproj subproj-merge-spl3
154 # make sure exactly the right set of files ends up in the mainline
155 mainfiles
=$
(git ls-files | fixnl
)
156 check_equal
"$mainfiles" "$chkm $chkms_sub $chks_sub"
158 # make sure each filename changed exactly once in the entire history.
159 # 'main-sub??' and '/subdir/main-sub??' both change, because those are the
160 # changes that were split into their own history. And 'subdir/sub??' never
161 # change, since they were *only* changed in the subtree branch.
162 allchanges
=$
(git log
--name-only --pretty=format
:'' |
sort | fixnl
)
163 check_equal
"$allchanges" "$chkm $chkms $chks $chkms_sub"
165 # make sure the --rejoin commits never make it into subproj
166 check_equal
"$(git log --pretty=format:'%s' HEAD^2 | grep -i split)" ""
168 # make sure no 'git subtree' tagged commits make it into subproj. (They're
169 # meaningless to subproj since one side of the merge refers to the mainline)
170 check_equal
"$(git log --pretty=format:'%s%n%b' HEAD^2 | grep 'git-subtree.*:')" ""
172 # make sure no patch changes more than one file. The original set of commits
173 # changed only one file each. A multi-file change would imply that we pruned
174 # commits too aggressively.
183 elif [ "$x" = "commit:" ]; then
184 if [ -n "$commit" ]; then
196 git log
--pretty=format
:'commit: %H' | joincommits |
197 ( while read commit a b
; do
198 echo "Verifying commit $commit"