@@ -11,54 +11,53 @@ and split subcommands of git subtree.
11
11
12
12
TEST_DIRECTORY=$( pwd) /../../../t
13
13
export TEST_DIRECTORY
14
+ . " $TEST_DIRECTORY " /test-lib.sh
14
15
15
- . ../../../t/test-lib.sh
16
-
17
- subtree_test_create_repo ()
18
- {
16
+ subtree_test_create_repo () {
19
17
test_create_repo " $1 " &&
20
18
(
21
19
cd " $1 " &&
22
20
git config log.date relative
23
21
)
24
22
}
25
23
26
- create ()
27
- {
24
+ create () {
28
25
echo " $1 " > " $1 " &&
29
26
git add " $1 "
30
27
}
31
28
32
- check_equal ()
33
- {
29
+ check_equal () {
34
30
test_debug ' echo'
35
31
test_debug " echo \" check a:\" \" {$1 }\" "
36
32
test_debug " echo \" b:\" \" {$2 }\" "
37
- if [ " $1 " = " $2 " ]; then
33
+ if test " $1 " = " $2 "
34
+ then
38
35
return 0
39
36
else
40
37
return 1
41
38
fi
42
39
}
43
40
44
- undo ()
45
- {
41
+ undo () {
46
42
git reset --hard HEAD~
47
43
}
48
44
49
45
# Make sure no patch changes more than one file.
50
46
# The original set of commits changed only one file each.
51
47
# A multi-file change would imply that we pruned commits
52
48
# too aggressively.
53
- join_commits ()
54
- {
49
+ join_commits () {
55
50
commit=
56
51
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
59
56
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
62
61
echo " $commit $all "
63
62
all=
64
63
fi
@@ -70,7 +69,7 @@ join_commits()
70
69
echo " $commit $all "
71
70
}
72
71
73
- test_create_commit () (
72
+ test_create_commit () (
74
73
repo=$1 &&
75
74
commit=$2 &&
76
75
cd " $repo " &&
@@ -81,8 +80,7 @@ test_create_commit() (
81
80
git commit -m " $commit " || error " Could not commit"
82
81
)
83
82
84
- last_commit_message ()
85
- {
83
+ last_commit_message () {
86
84
git log --pretty=format:%s -1
87
85
}
88
86
@@ -111,7 +109,8 @@ test_expect_success 'no pull from non-existent subtree' '
111
109
cd "$test_count" &&
112
110
git fetch ./"sub proj" HEAD &&
113
111
test_must_fail git subtree pull --prefix="sub dir" ./"sub proj" HEAD
114
- )'
112
+ )
113
+ '
115
114
116
115
test_expect_success ' add subproj as subtree into sub dir/ with --prefix' '
117
116
subtree_test_create_repo "$test_count" &&
@@ -274,8 +273,8 @@ test_expect_success 'split requires option --prefix' '
274
273
cd "$test_count" &&
275
274
git fetch ./"sub proj" HEAD &&
276
275
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 &&
279
278
test_debug "printf ' " expected: " ' " &&
280
279
test_debug "cat expected" &&
281
280
test_debug "printf ' " actual: " ' " &&
@@ -293,8 +292,8 @@ test_expect_success 'split requires path given by option --prefix must exist' '
293
292
cd "$test_count" &&
294
293
git fetch ./"sub proj" HEAD &&
295
294
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 &&
298
297
test_debug "printf ' " expected: " ' " &&
299
298
test_debug "cat expected" &&
300
299
test_debug "printf ' " actual: " ' " &&
@@ -325,7 +324,7 @@ test_expect_success 'split sub dir/ with --rejoin' '
325
324
git subtree split --prefix="sub dir" --annotate="*" --rejoin &&
326
325
check_equal "$(last_commit_message)" "Split ' \' ' sub dir/' \' ' into commit ' \' ' $split_hash' \' ' "
327
326
)
328
- '
327
+ '
329
328
330
329
test_expect_success ' split sub dir/ with --rejoin from scratch' '
331
330
subtree_test_create_repo "$test_count" &&
@@ -340,7 +339,7 @@ test_expect_success 'split sub dir/ with --rejoin from scratch' '
340
339
git subtree split --prefix="sub dir" --rejoin &&
341
340
check_equal "$(last_commit_message)" "Split ' \' ' sub dir/' \' ' into commit ' \' ' $split_hash' \' ' "
342
341
)
343
- '
342
+ '
344
343
345
344
test_expect_success ' split sub dir/ with --rejoin and --message' '
346
345
subtree_test_create_repo "$test_count" &&
@@ -893,7 +892,8 @@ test_expect_success 'verify one file change per commit' '
893
892
x= &&
894
893
git log --pretty=format:"commit: %H" | join_commits |
895
894
(
896
- while read commit a b; do
895
+ while read commit a b
896
+ do
897
897
test_debug "echo Verifying commit $commit"
898
898
test_debug "echo a: $a"
899
899
test_debug "echo b: $b"
@@ -921,18 +921,18 @@ test_expect_success 'push split to subproj' '
921
921
test_create_commit "$test_count" "sub dir"/main-sub2 &&
922
922
(
923
923
cd $test_count/"sub proj" &&
924
- git branch sub-branch-1 &&
925
- cd .. &&
924
+ git branch sub-branch-1 &&
925
+ cd .. &&
926
926
git fetch ./"sub proj" HEAD &&
927
927
git subtree merge --prefix="sub dir" FETCH_HEAD
928
928
) &&
929
929
test_create_commit "$test_count" "sub dir"/main-sub3 &&
930
- (
930
+ (
931
931
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"
936
936
)
937
937
'
938
938
0 commit comments