test.sh: make sure no commit changes more than one file at a time.
Avery Pennarun committed
Apr 26, 2009 at 17:43 UTC
fa16ab36ad014bcc03acc4313bb0918fb241b54d
1 file changed
+34
test.sh
+34
@@ -169,5 +169,39 @@ check_equal "$(git log --pretty=format:'%s' HEAD^2 | grep -i split)" ""
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.*:')" ""
171
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.
175
+joincommits()
176
+{
177
+ echo "hello world"
178
+ commit=
179
+ all=
180
+ while read x y; do
181
+ echo "{$x}" >&2
182
+ if [ -z "$x" ]; then
183
+ continue
184
+ elif [ "$x" = "commit:" ]; then
185
+ if [ -n "$commit" ]; then
186
+ echo "$commit $all"
187
+ all=
188
+ fi
189
+ commit="$y"
190
+ else
191
+ all="$all $y"
192
+ fi
193
+ done
194
+ echo "$commit $all"
195
+}
196
+x=0
197
+git log --pretty=format:'commit: %H' | joincommits |
198
+( while read commit a b; do
199
+ echo "Verifying commit $commit"
200
+ check_equal "$b" ""
201
+ x=$(($x + 1))
202
+ done
203
+ check_equal $x 23
204
+) || exit 1
205
+
206
echo
207
echo 'ok'