subtree: t7900: use consistent formatting

The formatting in t7900-subtree.sh isn't even consistent throughout the file. Fix that; make it consistent throughout the file. Signed-off-by: Luke Shumaker <lukeshu@datawire.io> Signed-off-by: Junio C Hamano <gitster@pobox.com>

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