]> asedeno.scripts.mit.edu Git - git.git/blobdiff - t/t7407-submodule-foreach.sh
Merge branch 'rr/parse-date-refactor'
[git.git] / t / t7407-submodule-foreach.sh
index de1730d6382f0ad7168d97fba65acdc9ae93e789..db9365b6454b18eb07f5c0798e13e18d696498c6 100755 (executable)
@@ -59,11 +59,13 @@ test_expect_success 'setup a submodule tree' '
 sub1sha1=$(cd super/sub1 && git rev-parse HEAD)
 sub3sha1=$(cd super/sub3 && git rev-parse HEAD)
 
+pwd=$(pwd)
+
 cat > expect <<EOF
 Entering 'sub1'
-foo1-sub1-$sub1sha1
+$pwd/clone-foo1-sub1-$sub1sha1
 Entering 'sub3'
-foo3-sub3-$sub3sha1
+$pwd/clone-foo3-sub3-$sub3sha1
 EOF
 
 test_expect_success 'test basic "submodule foreach" usage' '
@@ -71,7 +73,9 @@ test_expect_success 'test basic "submodule foreach" usage' '
        (
                cd clone &&
                git submodule update --init -- sub1 sub3 &&
-               git submodule foreach "echo \$name-\$path-\$sha1" > ../actual
+               git submodule foreach "echo \$toplevel-\$name-\$path-\$sha1" > ../actual &&
+               git config foo.bar zar &&
+               git submodule foreach "git config --file \"\$toplevel/.git/config\" foo.bar"
        ) &&
        test_cmp expect actual
 '
@@ -201,14 +205,16 @@ submodulesha1=$(cd clone3/nested1/nested2/nested3/submodule && git rev-parse HEA
 sub1sha1=$(cd clone3/sub1 && git rev-parse HEAD)
 sub2sha1=$(cd clone3/sub2 && git rev-parse HEAD)
 sub3sha1=$(cd clone3/sub3 && git rev-parse HEAD)
+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)
- $sub1sha1 sub1 (${sub1sha1:0:7})
- $sub2sha1 sub2 (${sub1sha1:0:7})
+ $sub1sha1 sub1 ($sub1sha1_short)
+ $sub2sha1 sub2 ($sub2sha1_short)
  $sub3sha1 sub3 (heads/master)
 EOF
 
@@ -220,4 +226,16 @@ test_expect_success 'test "status --recursive"' '
        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
+'
+
 test_done