@@ -11,54 +11,53 @@ and split subcommands of git subtree.
1111
1212TEST_DIRECTORY=$( pwd) /../../../t
1313export TEST_DIRECTORY
14+ . " $TEST_DIRECTORY " /test-lib.sh
1415
15- . ../../../t/test-lib.sh
16-
17- subtree_test_create_repo ()
18- {
16+ subtree_test_create_repo () {
1917 test_create_repo " $1 " &&
2018 (
2119 cd " $1 " &&
2220 git config log.date relative
2321 )
2422}
2523
26- create ()
27- {
24+ create () {
2825 echo " $1 " > " $1 " &&
2926 git add " $1 "
3027}
3128
32- check_equal ()
33- {
29+ check_equal () {
3430 test_debug ' echo'
3531 test_debug " echo \" check a:\" \" {$1 }\" "
3632 test_debug " echo \" b:\" \" {$2 }\" "
37- if [ " $1 " = " $2 " ]; then
33+ if test " $1 " = " $2 "
34+ then
3835 return 0
3936 else
4037 return 1
4138 fi
4239}
4340
44- undo ()
45- {
41+ undo () {
4642 git reset --hard HEAD~
4743}
4844
4945# Make sure no patch changes more than one file.
5046# The original set of commits changed only one file each.
5147# A multi-file change would imply that we pruned commits
5248# too aggressively.
53- join_commits ()
54- {
49+ join_commits () {
5550 commit=
5651 all=
57- while read x y; do
58- if [ -z " $x " ]; then
52+ while read x y
53+ do
54+ if test -z " $x "
55+ then
5956 continue
60- elif [ " $x " = " commit:" ]; then
61- if [ -n " $commit " ]; then
57+ elif test " $x " = " commit:"
58+ then
59+ if test -n " $commit "
60+ then
6261 echo " $commit $all "
6362 all=
6463 fi
@@ -70,7 +69,7 @@ join_commits()
7069 echo " $commit $all "
7170}
7271
73- test_create_commit () (
72+ test_create_commit () (
7473 repo=$1 &&
7574 commit=$2 &&
7675 cd " $repo " &&
@@ -81,8 +80,7 @@ test_create_commit() (
8180 git commit -m " $commit " || error " Could not commit"
8281)
8382
84- last_commit_message ()
85- {
83+ last_commit_message () {
8684 git log --pretty=format:%s -1
8785}
8886
@@ -111,7 +109,8 @@ test_expect_success 'no pull from non-existent subtree' '
111109 cd "$test_count" &&
112110 git fetch ./"sub proj" HEAD &&
113111 test_must_fail git subtree pull --prefix="sub dir" ./"sub proj" HEAD
114- )'
112+ )
113+ '
115114
116115test_expect_success ' add subproj as subtree into sub dir/ with --prefix' '
117116 subtree_test_create_repo "$test_count" &&
@@ -274,8 +273,8 @@ test_expect_success 'split requires option --prefix' '
274273 cd "$test_count" &&
275274 git fetch ./"sub proj" HEAD &&
276275 git subtree add --prefix="sub dir" FETCH_HEAD &&
277- echo "You must provide the --prefix option." > expected &&
278- test_must_fail git subtree split > actual 2>&1 &&
276+ echo "You must provide the --prefix option." >expected &&
277+ test_must_fail git subtree split >actual 2>&1 &&
279278 test_debug "printf ' " expected: " ' " &&
280279 test_debug "cat expected" &&
281280 test_debug "printf ' " actual: " ' " &&
@@ -293,8 +292,8 @@ test_expect_success 'split requires path given by option --prefix must exist' '
293292 cd "$test_count" &&
294293 git fetch ./"sub proj" HEAD &&
295294 git subtree add --prefix="sub dir" FETCH_HEAD &&
296- echo "' \' ' non-existent-directory' \' ' does not exist; use ' \' ' git subtree add' \' ' " > expected &&
297- test_must_fail git subtree split --prefix=non-existent-directory > actual 2>&1 &&
295+ echo "' \' ' non-existent-directory' \' ' does not exist; use ' \' ' git subtree add' \' ' " >expected &&
296+ test_must_fail git subtree split --prefix=non-existent-directory >actual 2>&1 &&
298297 test_debug "printf ' " expected: " ' " &&
299298 test_debug "cat expected" &&
300299 test_debug "printf ' " actual: " ' " &&
@@ -325,7 +324,7 @@ test_expect_success 'split sub dir/ with --rejoin' '
325324 git subtree split --prefix="sub dir" --annotate="*" --rejoin &&
326325 check_equal "$(last_commit_message)" "Split ' \' ' sub dir/' \' ' into commit ' \' ' $split_hash' \' ' "
327326 )
328- '
327+ '
329328
330329test_expect_success ' split sub dir/ with --rejoin from scratch' '
331330 subtree_test_create_repo "$test_count" &&
@@ -340,7 +339,7 @@ test_expect_success 'split sub dir/ with --rejoin from scratch' '
340339 git subtree split --prefix="sub dir" --rejoin &&
341340 check_equal "$(last_commit_message)" "Split ' \' ' sub dir/' \' ' into commit ' \' ' $split_hash' \' ' "
342341 )
343- '
342+ '
344343
345344test_expect_success ' split sub dir/ with --rejoin and --message' '
346345 subtree_test_create_repo "$test_count" &&
@@ -893,7 +892,8 @@ test_expect_success 'verify one file change per commit' '
893892 x= &&
894893 git log --pretty=format:"commit: %H" | join_commits |
895894 (
896- while read commit a b; do
895+ while read commit a b
896+ do
897897 test_debug "echo Verifying commit $commit"
898898 test_debug "echo a: $a"
899899 test_debug "echo b: $b"
@@ -921,18 +921,18 @@ test_expect_success 'push split to subproj' '
921921 test_create_commit "$test_count" "sub dir"/main-sub2 &&
922922 (
923923 cd $test_count/"sub proj" &&
924- git branch sub-branch-1 &&
925- cd .. &&
924+ git branch sub-branch-1 &&
925+ cd .. &&
926926 git fetch ./"sub proj" HEAD &&
927927 git subtree merge --prefix="sub dir" FETCH_HEAD
928928 ) &&
929929 test_create_commit "$test_count" "sub dir"/main-sub3 &&
930- (
930+ (
931931 cd "$test_count" &&
932- git subtree push ./"sub proj" --prefix "sub dir" sub-branch-1 &&
933- cd ./"sub proj" &&
934- git checkout sub-branch-1 &&
935- check_equal "$(last_commit_message)" "sub dir/main-sub3"
932+ git subtree push ./"sub proj" --prefix "sub dir" sub-branch-1 &&
933+ cd ./"sub proj" &&
934+ git checkout sub-branch-1 &&
935+ check_equal "$(last_commit_message)" "sub dir/main-sub3"
936936 )
937937'
938938
0 commit comments