summaryrefslogtreecommitdiff
path: root/t/t7407-submodule-foreach.sh
diff options
context:
space:
mode:
Diffstat (limited to 't/t7407-submodule-foreach.sh')
-rwxr-xr-xt/t7407-submodule-foreach.sh43
1 files changed, 26 insertions, 17 deletions
diff --git a/t/t7407-submodule-foreach.sh b/t/t7407-submodule-foreach.sh
index 6b2aa91..8d7b234 100755
--- a/t/t7407-submodule-foreach.sh
+++ b/t/t7407-submodule-foreach.sh
@@ -9,10 +9,14 @@ This test verifies that "git submodule foreach" correctly visits all submodules
that are currently checked out.
'
+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+
. ./test-lib.sh
test_expect_success 'setup a submodule tree' '
+ git config --global protocol.file.allow always &&
echo file > file &&
git add file &&
test_tick &&
@@ -77,7 +81,7 @@ test_expect_success 'test basic "submodule foreach" usage' '
git config foo.bar zar &&
git submodule foreach "git config --file \"\$toplevel/.git/config\" foo.bar"
) &&
- test_i18ncmp expect actual
+ test_cmp expect actual
'
cat >expect <<EOF
@@ -93,7 +97,7 @@ test_expect_success 'test "submodule foreach" from subdirectory' '
cd clone/sub &&
git submodule foreach "echo \$toplevel-\$name-\$sm_path-\$displaypath-\$sha1" >../../actual
) &&
- test_i18ncmp expect actual
+ test_cmp expect actual
'
test_expect_success 'setup nested submodules' '
@@ -150,6 +154,11 @@ test_expect_success 'use "submodule foreach" to checkout 2nd level submodule' '
)
'
+test_expect_success 'usage: foreach -- --not-an-option' '
+ test_expect_code 1 git submodule foreach -- --not-an-option &&
+ test_expect_code 1 git -C clone2 submodule foreach -- --not-an-option
+'
+
test_expect_success 'use "foreach --recursive" to checkout all submodules' '
(
cd clone2 &&
@@ -174,7 +183,7 @@ test_expect_success 'test messages from "foreach --recursive"' '
cd clone2 &&
git submodule foreach --recursive "true" > ../actual
) &&
- test_i18ncmp expect actual
+ test_cmp expect actual
'
cat > expect <<EOF
@@ -194,7 +203,7 @@ test_expect_success 'test messages from "foreach --recursive" from subdirectory'
cd untracked &&
git submodule foreach --recursive >../../actual
) &&
- test_i18ncmp expect actual
+ test_cmp expect actual
'
sub1sha1=$(cd clone2/sub1 && git rev-parse HEAD)
sub2sha1=$(cd clone2/sub2 && git rev-parse HEAD)
@@ -226,7 +235,7 @@ test_expect_success 'test "submodule foreach --recursive" from subdirectory' '
cd clone2/untracked &&
git submodule foreach --recursive "echo toplevel: \$toplevel name: \$name path: \$sm_path displaypath: \$displaypath hash: \$sha1" >../../actual
) &&
- test_i18ncmp expect actual
+ test_cmp expect actual
'
cat > expect <<EOF
@@ -277,13 +286,13 @@ sub1sha1_short=$(cd clone3/sub1 && git rev-parse --short HEAD)
sub2sha1_short=$(cd clone3/sub2 && git rev-parse --short HEAD)
cat > expect <<EOF
- $nested1sha1 nested1 (heads/master)
- $nested2sha1 nested1/nested2 (heads/master)
- $nested3sha1 nested1/nested2/nested3 (heads/master)
- $submodulesha1 nested1/nested2/nested3/submodule (heads/master)
+ $nested1sha1 nested1 (heads/main)
+ $nested2sha1 nested1/nested2 (heads/main)
+ $nested3sha1 nested1/nested2/nested3 (heads/main)
+ $submodulesha1 nested1/nested2/nested3/submodule (heads/main)
$sub1sha1 sub1 ($sub1sha1_short)
$sub2sha1 sub2 ($sub2sha1_short)
- $sub3sha1 sub3 (heads/master)
+ $sub3sha1 sub3 (heads/main)
EOF
test_expect_success 'test "status --recursive"' '
@@ -295,10 +304,10 @@ test_expect_success 'test "status --recursive"' '
'
cat > expect <<EOF
- $nested1sha1 nested1 (heads/master)
+ $nested1sha1 nested1 (heads/main)
+$nested2sha1 nested1/nested2 (file2~1)
- $nested3sha1 nested1/nested2/nested3 (heads/master)
- $submodulesha1 nested1/nested2/nested3/submodule (heads/master)
+ $nested3sha1 nested1/nested2/nested3 (heads/main)
+ $submodulesha1 nested1/nested2/nested3/submodule (heads/main)
EOF
test_expect_success 'ensure "status --cached --recursive" preserves the --cached flag' '
@@ -316,13 +325,13 @@ test_expect_success 'ensure "status --cached --recursive" preserves the --cached
nested2sha1=$(git -C clone3/nested1/nested2 rev-parse HEAD)
cat > expect <<EOF
- $nested1sha1 ../nested1 (heads/master)
+ $nested1sha1 ../nested1 (heads/main)
+$nested2sha1 ../nested1/nested2 (file2)
- $nested3sha1 ../nested1/nested2/nested3 (heads/master)
- $submodulesha1 ../nested1/nested2/nested3/submodule (heads/master)
+ $nested3sha1 ../nested1/nested2/nested3 (heads/main)
+ $submodulesha1 ../nested1/nested2/nested3/submodule (heads/main)
$sub1sha1 ../sub1 ($sub1sha1_short)
$sub2sha1 ../sub2 ($sub2sha1_short)
- $sub3sha1 ../sub3 (heads/master)
+ $sub3sha1 ../sub3 (heads/main)
EOF
test_expect_success 'test "status --recursive" from sub directory' '