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
83 git fetch ..
/subproj sub1
84 git branch sub1 FETCH_HEAD
85 git subtree add
--prefix=subdir
/ FETCH_HEAD
87 # this shouldn't actually do anything, since FETCH_HEAD is already a parent
88 git merge
-m 'merge -s -ours' -s ours FETCH_HEAD
90 create subdir
/main-sub5
91 git commit
-m 'main-sub5'
94 git commit
-m 'main6 boring'
96 create subdir
/main-sub7
97 git commit
-m 'main-sub7'
99 git fetch ..
/subproj sub2
100 git branch sub2 FETCH_HEAD
101 git subtree merge
--prefix=subdir FETCH_HEAD
104 spl1
=$
(git subtree
split --annotate='*' \
105 --prefix subdir
--onto FETCH_HEAD
--rejoin)
107 git branch spl1
"$spl1"
109 create subdir
/main-sub8
110 git commit
-m 'main-sub8'
113 git fetch ..
/mainline spl1
114 git branch spl1 FETCH_HEAD
121 split2
=$
(git subtree
split --annotate='*' --prefix subdir
/ --rejoin)
122 git branch split2
"$split2"
124 create subdir
/main-sub10
125 git commit
-m 'main-sub10'
127 spl3
=$
(git subtree
split --annotate='*' --prefix subdir
--rejoin)
128 git branch spl3
"$spl3"
131 git fetch ..
/mainline spl3
132 git branch spl3 FETCH_HEAD
134 git branch subproj-merge-spl3
137 chkms
="main-sub10 main-sub5 main-sub7 main-sub8"
138 chkms_sub
=$
(echo $chkms | multiline |
sed 's,^,subdir/,' | fixnl
)
139 chks
="sub1 sub2 sub3 sub9"
140 chks_sub
=$
(echo $chks | multiline |
sed 's,^,subdir/,' | fixnl
)
142 # make sure exactly the right set of files ends up in the subproj
143 subfiles
=$
(git ls-files | fixnl
)
144 check_equal
"$subfiles" "$chkms $chks"
146 # make sure the subproj history *only* contains commits that affect the subdir.
147 allchanges
=$
(git log
--name-only --pretty=format
:'' |
sort | fixnl
)
148 check_equal
"$allchanges" "$chkms $chks"
151 git fetch ..
/subproj subproj-merge-spl3
152 git branch subproj-merge-spl3 FETCH_HEAD
153 git subtree pull
--prefix=subdir ..
/subproj subproj-merge-spl3
155 # make sure exactly the right set of files ends up in the mainline
156 mainfiles
=$
(git ls-files | fixnl
)
157 check_equal
"$mainfiles" "$chkm $chkms_sub $chks_sub"
159 # make sure each filename changed exactly once in the entire history.
160 # 'main-sub??' and '/subdir/main-sub??' both change, because those are the
161 # changes that were split into their own history. And 'subdir/sub??' never
162 # change, since they were *only* changed in the subtree branch.
163 allchanges
=$
(git log
--name-only --pretty=format
:'' |
sort | fixnl
)
164 check_equal
"$allchanges" "$(echo $chkms $chkm $chks $chkms_sub | multiline | sort | fixnl)"
166 # make sure the --rejoin commits never make it into subproj
167 check_equal
"$(git log --pretty=format:'%s' HEAD^2 | grep -i split)" ""
169 # make sure no 'git subtree' tagged commits make it into subproj. (They're
170 # meaningless to subproj since one side of the merge refers to the mainline)
171 check_equal
"$(git log --pretty=format:'%s%n%b' HEAD^2 | grep 'git-subtree.*:')" ""
173 # make sure no patch changes more than one file. The original set of commits
174 # changed only one file each. A multi-file change would imply that we pruned
175 # commits too aggressively.
184 elif [ "$x" = "commit:" ]; then
185 if [ -n "$commit" ]; then
197 git log
--pretty=format
:'commit: %H' | joincommits |
198 ( while read commit a b
; do
199 echo "Verifying commit $commit"