Merge branch 'jj/rev-list-options-doc'
[gitweb.git] / t / t7407-submodule-foreach.sh
index 835a50624114253b634896e1cceae43578a279bf..b64c9ed8e73644b52aff38c7b4dca248ab690c73 100755 (executable)
@@ -77,7 +77,23 @@ 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_cmp expect actual
+       test_i18ncmp expect actual
+'
+
+cat >expect <<EOF
+Entering '../sub1'
+$pwd/clone-foo1-../sub1-$sub1sha1
+Entering '../sub3'
+$pwd/clone-foo3-../sub3-$sub3sha1
+EOF
+
+test_expect_success 'test "submodule foreach" from subdirectory' '
+       mkdir clone/sub &&
+       (
+               cd clone/sub &&
+               git submodule foreach "echo \$toplevel-\$name-\$sm_path-\$sha1" >../../actual
+       ) &&
+       test_i18ncmp expect actual
 '
 
 test_expect_success 'setup nested submodules' '
@@ -118,19 +134,19 @@ test_expect_success 'use "submodule foreach" to checkout 2nd level submodule' '
        git clone super clone2 &&
        (
                cd clone2 &&
-               test ! -d sub1/.git &&
-               test ! -d sub2/.git &&
-               test ! -d sub3/.git &&
-               test ! -d nested1/.git &&
+               test_must_fail git rev-parse --resolve-git-dir sub1/.git &&
+               test_must_fail git rev-parse --resolve-git-dir sub2/.git &&
+               test_must_fail git rev-parse --resolve-git-dir sub3/.git &&
+               test_must_fail git rev-parse --resolve-git-dir nested1/.git &&
                git submodule update --init &&
-               test -d sub1/.git &&
-               test -d sub2/.git &&
-               test -d sub3/.git &&
-               test -d nested1/.git &&
-               test ! -d nested1/nested2/.git &&
+               git rev-parse --resolve-git-dir sub1/.git &&
+               git rev-parse --resolve-git-dir sub2/.git &&
+               git rev-parse --resolve-git-dir sub3/.git &&
+               git rev-parse --resolve-git-dir nested1/.git &&
+               test_must_fail git rev-parse --resolve-git-dir nested1/nested2/.git &&
                git submodule foreach "git submodule update --init" &&
-               test -d nested1/nested2/.git &&
-               test ! -d nested1/nested2/nested3/.git
+               git rev-parse --resolve-git-dir nested1/nested2/.git &&
+               test_must_fail git rev-parse --resolve-git-dir nested1/nested2/nested3/.git
        )
 '
 
@@ -138,8 +154,8 @@ test_expect_success 'use "foreach --recursive" to checkout all submodules' '
        (
                cd clone2 &&
                git submodule foreach --recursive "git submodule update --init" &&
-               test -d nested1/nested2/nested3/.git &&
-               test -d nested1/nested2/nested3/submodule/.git
+               git rev-parse --resolve-git-dir nested1/nested2/nested3/.git &&
+               git rev-parse --resolve-git-dir nested1/nested2/nested3/submodule/.git
        )
 '
 
@@ -158,7 +174,7 @@ test_expect_success 'test messages from "foreach --recursive"' '
                cd clone2 &&
                git submodule foreach --recursive "true" > ../actual
        ) &&
-       test_cmp expect actual
+       test_i18ncmp expect actual
 '
 
 cat > expect <<EOF
@@ -183,18 +199,18 @@ test_expect_success 'use "update --recursive" to checkout all submodules' '
        git clone super clone3 &&
        (
                cd clone3 &&
-               test ! -d sub1/.git &&
-               test ! -d sub2/.git &&
-               test ! -d sub3/.git &&
-               test ! -d nested1/.git &&
+               test_must_fail git rev-parse --resolve-git-dir sub1/.git &&
+               test_must_fail git rev-parse --resolve-git-dir sub2/.git &&
+               test_must_fail git rev-parse --resolve-git-dir sub3/.git &&
+               test_must_fail git rev-parse --resolve-git-dir nested1/.git &&
                git submodule update --init --recursive &&
-               test -d sub1/.git &&
-               test -d sub2/.git &&
-               test -d sub3/.git &&
-               test -d nested1/.git &&
-               test -d nested1/nested2/.git &&
-               test -d nested1/nested2/nested3/.git &&
-               test -d nested1/nested2/nested3/submodule/.git
+               git rev-parse --resolve-git-dir sub1/.git &&
+               git rev-parse --resolve-git-dir sub2/.git &&
+               git rev-parse --resolve-git-dir sub3/.git &&
+               git rev-parse --resolve-git-dir nested1/.git &&
+               git rev-parse --resolve-git-dir nested1/nested2/.git &&
+               git rev-parse --resolve-git-dir nested1/nested2/nested3/.git &&
+               git rev-parse --resolve-git-dir nested1/nested2/nested3/submodule/.git
        )
 '
 
@@ -226,35 +242,34 @@ test_expect_success 'test "status --recursive"' '
        test_cmp expect actual
 '
 
-sed -e "/nested1 /s/.*/+$nested1sha1 nested1 (file2~1)/;/sub[1-3]/d" < expect > expect2
+sed -e "/nested2 /s/.*/+$nested2sha1 nested1\/nested2 (file2~1)/;/sub[1-3]/d" < expect > expect2
 mv -f expect2 expect
 
 test_expect_success 'ensure "status --cached --recursive" preserves the --cached flag' '
        (
                cd clone3 &&
                (
-                       cd nested1 &&
+                       cd nested1/nested2 &&
                        test_commit file2
                ) &&
                git submodule status --cached --recursive -- nested1 > ../actual
        ) &&
-       if test_have_prereq MINGW
-       then
-               dos2unix actual
-       fi &&
        test_cmp expect actual
 '
 
 test_expect_success 'use "git clone --recursive" to checkout all submodules' '
        git clone --recursive super clone4 &&
-       test -d clone4/.git &&
-       test -d clone4/sub1/.git &&
-       test -d clone4/sub2/.git &&
-       test -d clone4/sub3/.git &&
-       test -d clone4/nested1/.git &&
-       test -d clone4/nested1/nested2/.git &&
-       test -d clone4/nested1/nested2/nested3/.git &&
-       test -d clone4/nested1/nested2/nested3/submodule/.git
+       (
+               cd clone4 &&
+               git rev-parse --resolve-git-dir .git &&
+               git rev-parse --resolve-git-dir sub1/.git &&
+               git rev-parse --resolve-git-dir sub2/.git &&
+               git rev-parse --resolve-git-dir sub3/.git &&
+               git rev-parse --resolve-git-dir nested1/.git &&
+               git rev-parse --resolve-git-dir nested1/nested2/.git &&
+               git rev-parse --resolve-git-dir nested1/nested2/nested3/.git &&
+               git rev-parse --resolve-git-dir nested1/nested2/nested3/submodule/.git
+       )
 '
 
 test_expect_success 'test "update --recursive" with a flag with spaces' '
@@ -262,14 +277,14 @@ test_expect_success 'test "update --recursive" with a flag with spaces' '
        git clone super clone5 &&
        (
                cd clone5 &&
-               test ! -d nested1/.git &&
+               test_must_fail git rev-parse --resolve-git-dir d nested1/.git &&
                git submodule update --init --recursive --reference="$(dirname "$PWD")/common objects" &&
-               test -d nested1/.git &&
-               test -d nested1/nested2/.git &&
-               test -d nested1/nested2/nested3/.git &&
-               test -f nested1/.git/objects/info/alternates &&
-               test -f nested1/nested2/.git/objects/info/alternates &&
-               test -f nested1/nested2/nested3/.git/objects/info/alternates
+               git rev-parse --resolve-git-dir nested1/.git &&
+               git rev-parse --resolve-git-dir nested1/nested2/.git &&
+               git rev-parse --resolve-git-dir nested1/nested2/nested3/.git &&
+               test -f .git/modules/nested1/objects/info/alternates &&
+               test -f .git/modules/nested1/modules/nested2/objects/info/alternates &&
+               test -f .git/modules/nested1/modules/nested2/modules/nested3/objects/info/alternates
        )
 '
 
@@ -277,18 +292,18 @@ test_expect_success 'use "update --recursive nested1" to checkout all submodules
        git clone super clone6 &&
        (
                cd clone6 &&
-               test ! -d sub1/.git &&
-               test ! -d sub2/.git &&
-               test ! -d sub3/.git &&
-               test ! -d nested1/.git &&
+               test_must_fail git rev-parse --resolve-git-dir sub1/.git &&
+               test_must_fail git rev-parse --resolve-git-dir sub2/.git &&
+               test_must_fail git rev-parse --resolve-git-dir sub3/.git &&
+               test_must_fail git rev-parse --resolve-git-dir nested1/.git &&
                git submodule update --init --recursive -- nested1 &&
-               test ! -d sub1/.git &&
-               test ! -d sub2/.git &&
-               test ! -d sub3/.git &&
-               test -d nested1/.git &&
-               test -d nested1/nested2/.git &&
-               test -d nested1/nested2/nested3/.git &&
-               test -d nested1/nested2/nested3/submodule/.git
+               test_must_fail git rev-parse --resolve-git-dir sub1/.git &&
+               test_must_fail git rev-parse --resolve-git-dir sub2/.git &&
+               test_must_fail git rev-parse --resolve-git-dir sub3/.git &&
+               git rev-parse --resolve-git-dir nested1/.git &&
+               git rev-parse --resolve-git-dir nested1/nested2/.git &&
+               git rev-parse --resolve-git-dir nested1/nested2/nested3/.git &&
+               git rev-parse --resolve-git-dir nested1/nested2/nested3/submodule/.git
        )
 '