Code

Merge branch 'hv/submodule-update-none'
authorJunio C Hamano <gitster@pobox.com>
Mon, 10 Oct 2011 22:56:17 +0000 (15:56 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 10 Oct 2011 22:56:17 +0000 (15:56 -0700)
* hv/submodule-update-none:
  add update 'none' flag to disable update of submodule by default
  submodule: move update configuration variable further up

1  2 
t/t7406-submodule-update.sh

index 1ae6b4e9364780a87ca379c8675f838bbf5ae3f8,58877d3b38786a6811e7ddbd78d54318c5abdece..33b292b8a8e992c98774ad6e51270a9babc7e6de
@@@ -30,6 -30,7 +30,7 @@@ test_expect_success 'setup a submodule 
        git clone super submodule &&
        git clone super rebasing &&
        git clone super merging &&
+       git clone super none &&
        (cd super &&
         git submodule add ../submodule submodule &&
         test_tick &&
         test_tick &&
         git commit -m "rebasing"
        )
+       (cd super &&
+        git submodule add ../none none &&
+        test_tick &&
+        git commit -m "none"
+       )
  '
  
  test_expect_success 'submodule update detaching the HEAD ' '
@@@ -298,6 -304,62 +304,62 @@@ test_expect_success 'submodule update i
        )
  '
  
+ test_expect_success 'submodule init picks up update=none' '
+       (cd super &&
+        git config -f .gitmodules submodule.none.update none &&
+        git submodule init none &&
+        test "none" = "$(git config submodule.none.update)"
+       )
+ '
+ test_expect_success 'submodule update - update=none in .git/config' '
+       (cd super &&
+        git config submodule.submodule.update none &&
+        (cd submodule &&
+         git checkout master &&
+         compare_head
+        ) &&
+        git diff --raw | grep "        submodule" &&
+        git submodule update &&
+        git diff --raw | grep "        submodule" &&
+        (cd submodule &&
+         compare_head
+        ) &&
+        git config --unset submodule.submodule.update &&
+        git submodule update submodule
+       )
+ '
+ test_expect_success 'submodule update - update=none in .git/config but --checkout given' '
+       (cd super &&
+        git config submodule.submodule.update none &&
+        (cd submodule &&
+         git checkout master &&
+         compare_head
+        ) &&
+        git diff --raw | grep "        submodule" &&
+        git submodule update --checkout &&
+        test_must_fail git diff --raw \| grep "        submodule" &&
+        (cd submodule &&
+         test_must_fail compare_head
+        ) &&
+        git config --unset submodule.submodule.update
+       )
+ '
+ test_expect_success 'submodule update --init skips submodule with update=none' '
+       (cd super &&
+        git add .gitmodules &&
+        git commit -m ".gitmodules"
+       ) &&
+       git clone super cloned &&
+       (cd cloned &&
+        git submodule update --init &&
+        test -e submodule/.git &&
+        test_must_fail test -e none/.git
+       )
+ '
  test_expect_success 'submodule update continues after checkout error' '
        (cd super &&
         git reset --hard HEAD &&
@@@ -408,7 -470,6 +470,7 @@@ test_expect_success 'submodule update e
         test_cmp expect actual
        )
  '
 +
  test_expect_success 'submodule update exit immediately after recursive rebase error' '
        (cd super &&
         git checkout master &&
         test_cmp expect actual
        )
  '
 +
 +test_expect_success 'add different submodules to the same path' '
 +      (cd super &&
 +       git submodule add ../submodule s1 &&
 +       test_must_fail git submodule add ../merging s1
 +      )
 +'
 +
 +test_expect_success 'submodule add places git-dir in superprojects git-dir' '
 +      (cd super &&
 +       mkdir deeper &&
 +       git submodule add ../submodule deeper/submodule &&
 +       (cd deeper/submodule &&
 +        git log > ../../expected
 +       ) &&
 +       (cd .git/modules/deeper/submodule &&
 +        git log > ../../../../actual
 +       ) &&
 +       test_cmp actual expected
 +      )
 +'
 +
 +test_expect_success 'submodule update places git-dir in superprojects git-dir' '
 +      (cd super &&
 +       git commit -m "added submodule"
 +      ) &&
 +      git clone super super2 &&
 +      (cd super2 &&
 +       git submodule init deeper/submodule &&
 +       git submodule update &&
 +       (cd deeper/submodule &&
 +        git log > ../../expected
 +       ) &&
 +       (cd .git/modules/deeper/submodule &&
 +        git log > ../../../../actual
 +       ) &&
 +       test_cmp actual expected
 +      )
 +'
 +
 +test_expect_success 'submodule add places git-dir in superprojects git-dir recursive' '
 +      (cd super2 &&
 +       (cd deeper/submodule &&
 +        git submodule add ../submodule subsubmodule &&
 +        (cd subsubmodule &&
 +         git log > ../../../expected
 +        ) &&
 +        git commit -m "added subsubmodule" &&
 +        git push
 +       ) &&
 +       (cd .git/modules/deeper/submodule/modules/subsubmodule &&
 +        git log > ../../../../../actual
 +       ) &&
 +       git add deeper/submodule &&
 +       git commit -m "update submodule" &&
 +       git push &&
 +       test_cmp actual expected
 +      )
 +'
 +
 +test_expect_success 'submodule update places git-dir in superprojects git-dir recursive' '
 +      mkdir super_update_r &&
 +      (cd super_update_r &&
 +       git init --bare
 +      ) &&
 +      mkdir subsuper_update_r &&
 +      (cd subsuper_update_r &&
 +       git init --bare
 +      ) &&
 +      mkdir subsubsuper_update_r &&
 +      (cd subsubsuper_update_r &&
 +       git init --bare
 +      ) &&
 +      git clone subsubsuper_update_r subsubsuper_update_r2 &&
 +      (cd subsubsuper_update_r2 &&
 +       test_commit "update_subsubsuper" file &&
 +       git push origin master
 +      ) &&
 +      git clone subsuper_update_r subsuper_update_r2 &&
 +      (cd subsuper_update_r2 &&
 +       test_commit "update_subsuper" file &&
 +       git submodule add ../subsubsuper_update_r subsubmodule &&
 +       git commit -am "subsubmodule" &&
 +       git push origin master
 +      ) &&
 +      git clone super_update_r super_update_r2 &&
 +      (cd super_update_r2 &&
 +       test_commit "update_super" file &&
 +       git submodule add ../subsuper_update_r submodule &&
 +       git commit -am "submodule" &&
 +       git push origin master
 +      ) &&
 +      rm -rf super_update_r2 &&
 +      git clone super_update_r super_update_r2 &&
 +      (cd super_update_r2 &&
 +       git submodule update --init --recursive &&
 +       (cd submodule/subsubmodule &&
 +        git log > ../../expected
 +       ) &&
 +       (cd .git/modules/submodule/modules/subsubmodule
 +        git log > ../../../../../actual
 +       )
 +       test_cmp actual expected
 +      )
 +'
 +
  test_done