subtree: t7900: use 'test' for string equality
t7900-subtree.sh defines its own `check_equal A B` function, instead of just using `test A = B` like all of the other tests. Don't be special, get rid of `check_equal` in favor of `test`. 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
c4566ab429c5a46a91c5b3bd351c545b91a2e593
1 file changed
+24
-36
contrib/subtree/t/t7900-subtree.sh
+24
-36
@@ -28,18 +28,6 @@ create () {
28
git add "$1"
29
}
30
31
-check_equal () {
32
- test_debug 'echo'
33
- test_debug "echo \"check a:\" \"{$1}\""
34
- test_debug "echo \" b:\" \"{$2}\""
35
- if test "$1" = "$2"
36
- then
37
- return 0
38
- else
39
- return 1
40
- fi
41
-}
42
-
31
undo () {
32
git reset --hard HEAD~
33
}
@@ -123,7 +111,7 @@ test_expect_success 'add subproj as subtree into sub dir/ with --prefix' '
111
cd "$test_count" &&
112
git fetch ./"sub proj" HEAD &&
113
git subtree add --prefix="sub dir" FETCH_HEAD &&
126
- check_equal "$(last_commit_message)" "Add '\''sub dir/'\'' from commit '\''$(git rev-parse FETCH_HEAD)'\''"
114
+ test "$(last_commit_message)" = "Add '\''sub dir/'\'' from commit '\''$(git rev-parse FETCH_HEAD)'\''"
115
)
116
'
117
@@ -136,7 +124,7 @@ test_expect_success 'add subproj as subtree into sub dir/ with --prefix and --me
124
cd "$test_count" &&
125
git fetch ./"sub proj" HEAD &&
126
git subtree add --prefix="sub dir" --message="Added subproject" FETCH_HEAD &&
139
- check_equal "$(last_commit_message)" "Added subproject"
127
+ test "$(last_commit_message)" = "Added subproject"
128
)
129
'
130
@@ -149,7 +137,7 @@ test_expect_success 'add subproj as subtree into sub dir/ with --prefix as -P an
137
cd "$test_count" &&
138
git fetch ./"sub proj" HEAD &&
139
git subtree add -P "sub dir" -m "Added subproject" FETCH_HEAD &&
152
- check_equal "$(last_commit_message)" "Added subproject"
140
+ test "$(last_commit_message)" = "Added subproject"
141
)
142
'
143
@@ -162,7 +150,7 @@ test_expect_success 'add subproj as subtree into sub dir/ with --squash and --pr
150
cd "$test_count" &&
151
git fetch ./"sub proj" HEAD &&
152
git subtree add --prefix="sub dir" --message="Added subproject with squash" --squash FETCH_HEAD &&
165
- check_equal "$(last_commit_message)" "Added subproject with squash"
153
+ test "$(last_commit_message)" = "Added subproject with squash"
154
)
155
'
156
@@ -185,7 +173,7 @@ test_expect_success 'merge new subproj history into sub dir/ with --prefix' '
173
cd "$test_count" &&
174
git fetch ./"sub proj" HEAD &&
175
git subtree merge --prefix="sub dir" FETCH_HEAD &&
188
- check_equal "$(last_commit_message)" "Merge commit '\''$(git rev-parse FETCH_HEAD)'\''"
176
+ test "$(last_commit_message)" = "Merge commit '\''$(git rev-parse FETCH_HEAD)'\''"
177
)
178
'
179
@@ -204,7 +192,7 @@ test_expect_success 'merge new subproj history into sub dir/ with --prefix and -
192
cd "$test_count" &&
193
git fetch ./"sub proj" HEAD &&
194
git subtree merge --prefix="sub dir" --message="Merged changes from subproject" FETCH_HEAD &&
207
- check_equal "$(last_commit_message)" "Merged changes from subproject"
195
+ test "$(last_commit_message)" = "Merged changes from subproject"
196
)
197
'
198
@@ -223,7 +211,7 @@ test_expect_success 'merge new subproj history into sub dir/ with --squash and -
211
cd "$test_count" &&
212
git fetch ./"sub proj" HEAD &&
213
git subtree merge --prefix="sub dir" --message="Merged changes from subproject using squash" --squash FETCH_HEAD &&
226
- check_equal "$(last_commit_message)" "Merged changes from subproject using squash"
214
+ test "$(last_commit_message)" = "Merged changes from subproject using squash"
215
)
216
'
217
@@ -239,7 +227,7 @@ test_expect_success 'merge the added subproj again, should do nothing' '
227
# this shouldn not actually do anything, since FETCH_HEAD
228
# is already a parent
229
result=$(git merge -s ours -m "merge -s -ours" FETCH_HEAD) &&
242
- check_equal "${result}" "Already up to date."
230
+ test "${result}" = "Already up to date."
231
)
232
'
233
@@ -258,7 +246,7 @@ test_expect_success 'merge new subproj history into subdir/ with a slash appende
246
cd "$test_count" &&
247
git fetch ./subproj HEAD &&
248
git subtree merge --prefix=subdir/ FETCH_HEAD &&
261
- check_equal "$(last_commit_message)" "Merge commit '\''$(git rev-parse FETCH_HEAD)'\''"
249
+ test "$(last_commit_message)" = "Merge commit '\''$(git rev-parse FETCH_HEAD)'\''"
250
)
251
'
252
@@ -324,7 +312,7 @@ test_expect_success 'split sub dir/ with --rejoin' '
312
git subtree merge --prefix="sub dir" FETCH_HEAD &&
313
split_hash=$(git subtree split --prefix="sub dir" --annotate="*") &&
314
git subtree split --prefix="sub dir" --annotate="*" --rejoin &&
327
- check_equal "$(last_commit_message)" "Split '\''sub dir/'\'' into commit '\''$split_hash'\''"
315
+ test "$(last_commit_message)" = "Split '\''sub dir/'\'' into commit '\''$split_hash'\''"
316
)
317
'
318
@@ -339,7 +327,7 @@ test_expect_success 'split sub dir/ with --rejoin from scratch' '
327
git commit -m"sub dir file" &&
328
split_hash=$(git subtree split --prefix="sub dir" --rejoin) &&
329
git subtree split --prefix="sub dir" --rejoin &&
342
- check_equal "$(last_commit_message)" "Split '\''sub dir/'\'' into commit '\''$split_hash'\''"
330
+ test "$(last_commit_message)" = "Split '\''sub dir/'\'' into commit '\''$split_hash'\''"
331
)
332
'
333
@@ -362,7 +350,7 @@ test_expect_success 'split sub dir/ with --rejoin and --message' '
350
git fetch ./"sub proj" HEAD &&
351
git subtree merge --prefix="sub dir" FETCH_HEAD &&
352
git subtree split --prefix="sub dir" --message="Split & rejoin" --annotate="*" --rejoin &&
365
- check_equal "$(last_commit_message)" "Split & rejoin"
353
+ test "$(last_commit_message)" = "Split & rejoin"
354
)
355
'
356
@@ -386,7 +374,7 @@ test_expect_success 'split "sub dir"/ with --branch' '
374
git subtree merge --prefix="sub dir" FETCH_HEAD &&
375
split_hash=$(git subtree split --prefix="sub dir" --annotate="*") &&
376
git subtree split --prefix="sub dir" --annotate="*" --branch subproj-br &&
389
- check_equal "$(git rev-parse subproj-br)" "$split_hash"
377
+ test "$(git rev-parse subproj-br)" = "$split_hash"
378
)
379
'
380
@@ -410,13 +398,13 @@ test_expect_success 'check hash of split' '
398
git subtree merge --prefix="sub dir" FETCH_HEAD &&
399
split_hash=$(git subtree split --prefix="sub dir" --annotate="*") &&
400
git subtree split --prefix="sub dir" --annotate="*" --branch subproj-br &&
413
- check_equal "$(git rev-parse subproj-br)" "$split_hash" &&
401
+ test "$(git rev-parse subproj-br)" = "$split_hash" &&
402
# Check hash of split
403
new_hash=$(git rev-parse subproj-br^2) &&
404
(
405
cd ./"sub proj" &&
406
subdir_hash=$(git rev-parse HEAD) &&
419
- check_equal ''"$new_hash"'' "$subdir_hash"
407
+ test ''"$new_hash"'' = "$subdir_hash"
408
)
409
)
410
'
@@ -442,7 +430,7 @@ test_expect_success 'split "sub dir"/ with --branch for an existing branch' '
430
git subtree merge --prefix="sub dir" FETCH_HEAD &&
431
split_hash=$(git subtree split --prefix="sub dir" --annotate="*") &&
432
git subtree split --prefix="sub dir" --annotate="*" --branch subproj-br &&
445
- check_equal "$(git rev-parse subproj-br)" "$split_hash"
433
+ test "$(git rev-parse subproj-br)" = "$split_hash"
434
)
435
'
436
@@ -740,7 +728,7 @@ test_expect_success 'make sure the --rejoin commits never make it into subproj'
728
(
729
cd "$test_count" &&
730
git subtree pull --prefix="sub dir" ./"sub proj" HEAD &&
743
- check_equal "$(git log --pretty=format:"%s" HEAD^2 | grep -i split)" ""
731
+ test "$(git log --pretty=format:"%s" HEAD^2 | grep -i split)" = ""
732
)
733
'
734
@@ -791,7 +779,7 @@ test_expect_success 'make sure no "git subtree" tagged commits make it into subp
779
git subtree pull --prefix="sub dir" ./"sub proj" HEAD &&
780
781
# They are meaningless to subproj since one side of the merge refers to the mainline
794
- check_equal "$(git log --pretty=format:"%s%n%b" HEAD^2 | grep "git-subtree.*:")" ""
782
+ test "$(git log --pretty=format:"%s%n%b" HEAD^2 | grep "git-subtree.*:")" = ""
783
)
784
'
785
@@ -825,7 +813,7 @@ test_expect_success 'make sure "git subtree split" find the correct parent' '
813
# not, something went wrong (the "newparent" of "HEAD~" commit should
814
# have been sub2, but it was not, because its cache was not set to
815
# itself)
828
- check_equal "$(git log --pretty=format:%P -1 subproj-br)" "$(git rev-parse subproj-ref)"
816
+ test "$(git log --pretty=format:%P -1 subproj-br)" = "$(git rev-parse subproj-ref)"
817
)
818
'
819
@@ -859,7 +847,7 @@ test_expect_success 'split a new subtree without --onto option' '
847
# if the parent of the first commit in the tree is not empty,
848
# then the new subtree has accidentally been attached to something
849
git subtree split --prefix="sub dir2" --branch subproj2-br &&
862
- check_equal "$(git log --pretty=format:%P -1 subproj2-br)" ""
850
+ test "$(git log --pretty=format:%P -1 subproj2-br)" = ""
851
)
852
'
853
@@ -899,10 +887,10 @@ test_expect_success 'verify one file change per commit' '
887
test_debug "echo Verifying commit $commit"
888
test_debug "echo a: $a"
889
test_debug "echo b: $b"
902
- check_equal "$b" ""
890
+ test "$b" = ""
891
x=1
892
done
905
- check_equal "$x" 1
893
+ test "$x" = 1
894
)
895
)
896
'
@@ -934,7 +922,7 @@ test_expect_success 'push split to subproj' '
922
git subtree push ./"sub proj" --prefix "sub dir" sub-branch-1 &&
923
cd ./"sub proj" &&
924
git checkout sub-branch-1 &&
937
- check_equal "$(last_commit_message)" "sub dir/main-sub3"
925
+ test "$(last_commit_message)" = "sub dir/main-sub3"
926
)
927
'
928
@@ -994,7 +982,7 @@ test_expect_success 'subtree descendant check' '
982
983
git subtree split --prefix folder_subtree/ --branch subtree_tip $defaultBranch &&
984
git subtree split --prefix folder_subtree/ --branch subtree_branch branch &&
997
- check_equal $(git rev-list --count subtree_tip..subtree_branch) 0
985
+ test $(git rev-list --count subtree_tip..subtree_branch) = 0
986
)
987
'
988