3 # Copyright (c) 2007 Lars Hjemli
6 test_description='Basic porcelain support for submodules
8 This test tries to verify basic sanity of the init, update and status
9 subcommands of git submodule.
14 test_expect_success 'setup - initial commit' '
17 git commit -m "initial commit" &&
21 test_expect_success 'submodule init aborts on missing .gitmodules file' '
22 test_when_finished "git update-index --remove sub" &&
23 git update-index --add --cacheinfo 160000,$(git rev-parse HEAD),sub &&
24 # missing the .gitmodules file here
25 test_must_fail git submodule init 2>actual &&
26 test_i18ngrep "No url found for submodule path" actual
29 test_expect_success 'configuration parsing' '
30 test_when_finished "rm -f .gitmodules" &&
31 cat >.gitmodules <<-\EOF &&
36 test_must_fail git status
39 test_expect_success 'setup - repository in init subdirectory' '
46 git commit -m "submodule commit 1" &&
47 git tag -a -m "rev-1" rev-1
51 test_expect_success 'setup - commit with gitlink' '
55 git commit -m "super commit 1"
58 test_expect_success 'setup - hide init subdirectory' '
62 test_expect_success 'setup - repository to add submodules to' '
64 git init addtest-ignore
67 # The 'submodule add' tests need some repository to add as a submodule.
68 # The trash directory is a good one as any. We need to canonicalize
69 # the name, though, as some tests compare it to the absolute path git
70 # generates, which will expand symbolic links.
74 git for-each-ref --format='%(refname)' 'refs/heads/*'
83 listbranches >"$dotdot/heads" &&
84 { git symbolic-ref HEAD || :; } >"$dotdot/head" &&
85 git rev-parse HEAD >"$dotdot/head-sha1" &&
86 git update-index --refresh &&
87 git diff-files --exit-code &&
88 git clean -n -d -x >"$dotdot/untracked"
92 test_expect_success 'submodule add' '
93 echo "refs/heads/master" >expect &&
98 git submodule add -q "$submodurl" submod >actual &&
99 test_must_be_empty actual &&
100 echo "gitdir: ../.git/modules/submod" >expect &&
101 test_cmp expect submod/.git &&
104 git config core.worktree >actual &&
105 echo "../../../submod" >expect &&
106 test_cmp expect actual &&
112 rm -f heads head untracked &&
113 inspect addtest/submod ../.. &&
114 test_cmp expect heads &&
115 test_cmp expect head &&
116 test_cmp empty untracked
119 test_expect_success 'submodule add to .gitignored path fails' '
122 cat <<-\EOF >expect &&
123 The following path is ignored by one of your .gitignore files:
125 Use -f if you really want to add it.
127 # Does not use test_commit due to the ignore
128 echo "*" > .gitignore &&
129 git add --force .gitignore &&
130 git commit -m"Ignore everything" &&
131 ! git submodule add "$submodurl" submod >actual 2>&1 &&
132 test_i18ncmp expect actual
136 test_expect_success 'submodule add to .gitignored path with --force' '
139 git submodule add --force "$submodurl" submod
143 test_expect_success 'submodule add --branch' '
144 echo "refs/heads/initial" >expect-head &&
145 cat <<-\EOF >expect-heads &&
153 git submodule add -b initial "$submodurl" submod-branch &&
154 test "initial" = "$(git config -f .gitmodules submodule.submod-branch.branch)" &&
158 rm -f heads head untracked &&
159 inspect addtest/submod-branch ../.. &&
160 test_cmp expect-heads heads &&
161 test_cmp expect-head head &&
162 test_cmp empty untracked
165 test_expect_success 'submodule add with ./ in path' '
166 echo "refs/heads/master" >expect &&
171 git submodule add "$submodurl" ././dotsubmod/./frotz/./ &&
175 rm -f heads head untracked &&
176 inspect addtest/dotsubmod/frotz ../../.. &&
177 test_cmp expect heads &&
178 test_cmp expect head &&
179 test_cmp empty untracked
182 test_expect_success 'submodule add with /././ in path' '
183 echo "refs/heads/master" >expect &&
188 git submodule add "$submodurl" dotslashdotsubmod/././frotz/./ &&
192 rm -f heads head untracked &&
193 inspect addtest/dotslashdotsubmod/frotz ../../.. &&
194 test_cmp expect heads &&
195 test_cmp expect head &&
196 test_cmp empty untracked
199 test_expect_success 'submodule add with // in path' '
200 echo "refs/heads/master" >expect &&
205 git submodule add "$submodurl" slashslashsubmod///frotz// &&
209 rm -f heads head untracked &&
210 inspect addtest/slashslashsubmod/frotz ../../.. &&
211 test_cmp expect heads &&
212 test_cmp expect head &&
213 test_cmp empty untracked
216 test_expect_success 'submodule add with /.. in path' '
217 echo "refs/heads/master" >expect &&
222 git submodule add "$submodurl" dotdotsubmod/../realsubmod/frotz/.. &&
226 rm -f heads head untracked &&
227 inspect addtest/realsubmod ../.. &&
228 test_cmp expect heads &&
229 test_cmp expect head &&
230 test_cmp empty untracked
233 test_expect_success 'submodule add with ./, /.. and // in path' '
234 echo "refs/heads/master" >expect &&
239 git submodule add "$submodurl" dot/dotslashsubmod/./../..////realsubmod2/a/b/c/d/../../../../frotz//.. &&
243 rm -f heads head untracked &&
244 inspect addtest/realsubmod2 ../.. &&
245 test_cmp expect heads &&
246 test_cmp expect head &&
247 test_cmp empty untracked
250 test_expect_success 'submodule add in subdirectory' '
251 echo "refs/heads/master" >expect &&
257 git submodule add "$submodurl" ../realsubmod3 &&
261 rm -f heads head untracked &&
262 inspect addtest/realsubmod3 ../.. &&
263 test_cmp expect heads &&
264 test_cmp expect head &&
265 test_cmp empty untracked
268 test_expect_success 'submodule add in subdirectory with relative path should fail' '
271 test_must_fail git submodule add ../../ submod3 2>../../output.err
273 test_i18ngrep toplevel output.err
276 test_expect_success 'setup - add an example entry to .gitmodules' '
277 git config --file=.gitmodules submodule.example.url git://example.com/init.git
280 test_expect_success 'status should fail for unmapped paths' '
281 test_must_fail git submodule status
284 test_expect_success 'setup - map path in .gitmodules' '
285 cat <<\EOF >expect &&
286 [submodule "example"]
287 url = git://example.com/init.git
291 git config --file=.gitmodules submodule.example.path init &&
293 test_cmp expect .gitmodules
296 test_expect_success 'status should only print one line' '
297 git submodule status >lines &&
298 test_line_count = 1 lines
301 test_expect_success 'setup - fetch commit name from submodule' '
302 rev1=$(cd .subrepo && git rev-parse HEAD) &&
303 printf "rev1: %s\n" "$rev1" &&
307 test_expect_success 'status should initially be "missing"' '
308 git submodule status >lines &&
312 test_expect_success 'init should register submodule url in .git/config' '
313 echo git://example.com/init.git >expect &&
315 git submodule init &&
316 git config submodule.example.url >url &&
317 git config submodule.example.url ./.subrepo &&
322 test_failure_with_unknown_submodule () {
323 test_must_fail git submodule $1 no-such-submodule 2>output.err &&
324 grep "^error: .*no-such-submodule" output.err
327 test_expect_success 'init should fail with unknown submodule' '
328 test_failure_with_unknown_submodule init
331 test_expect_success 'update should fail with unknown submodule' '
332 test_failure_with_unknown_submodule update
335 test_expect_success 'status should fail with unknown submodule' '
336 test_failure_with_unknown_submodule status
339 test_expect_success 'sync should fail with unknown submodule' '
340 test_failure_with_unknown_submodule sync
343 test_expect_success 'update should fail when path is used by a file' '
344 echo hello >expect &&
346 echo "hello" >init &&
347 test_must_fail git submodule update &&
352 test_expect_success 'update should fail when path is used by a nonempty directory' '
353 echo hello >expect &&
357 echo "hello" >init/a &&
359 test_must_fail git submodule update &&
361 test_cmp expect init/a
364 test_expect_success 'update should work when path is an empty dir' '
367 echo "$rev1" >expect &&
370 git submodule update -q >update.out &&
371 test_must_be_empty update.out &&
374 test_cmp expect head-sha1
377 test_expect_success 'status should be "up-to-date" after update' '
378 git submodule status >list &&
382 test_expect_success 'status "up-to-date" from subdirectory' '
386 git submodule status >../list
388 grep "^ $rev1" list &&
389 grep "\\.\\./init" list
392 test_expect_success 'status "up-to-date" from subdirectory with path' '
396 git submodule status ../init >../list
398 grep "^ $rev1" list &&
399 grep "\\.\\./init" list
402 test_expect_success 'status should be "modified" after submodule commit' '
407 git commit -m "submodule commit 2"
410 rev2=$(cd init && git rev-parse HEAD) &&
412 git submodule status >list &&
417 test_expect_success 'the --cached sha1 should be rev1' '
418 git submodule --cached status >list &&
422 test_expect_success 'git diff should report the SHA1 of the new submodule commit' '
424 grep "^+Subproject commit $rev2" diff
427 test_expect_success 'update should checkout rev1' '
429 echo "$rev1" >expect &&
431 git submodule update init &&
434 test_cmp expect head-sha1
437 test_expect_success 'status should be "up-to-date" after update' '
438 git submodule status >list &&
442 test_expect_success 'checkout superproject with subproject already present' '
443 git checkout initial &&
447 test_expect_success 'apply submodule diff' '
455 git commit -m "change subproject"
457 git update-index --add init &&
458 git commit -m "change init" &&
459 git format-patch -1 --stdout >P.diff &&
460 git checkout second &&
461 git apply --index P.diff &&
463 git diff --cached master >staged &&
464 test_cmp empty staged
467 test_expect_success 'update --init' '
469 git config -f .gitmodules submodule.example.url "$(pwd)/init2" &&
470 git config --remove-section submodule.example &&
471 test_must_fail git config submodule.example.url &&
473 git submodule update init 2> update.out &&
475 test_i18ngrep "not initialized" update.out &&
476 test_must_fail git rev-parse --resolve-git-dir init/.git &&
478 git submodule update --init init &&
479 git rev-parse --resolve-git-dir init/.git
482 test_expect_success 'update --init from subdirectory' '
484 git config -f .gitmodules submodule.example.url "$(pwd)/init2" &&
485 git config --remove-section submodule.example &&
486 test_must_fail git config submodule.example.url &&
491 git submodule update ../init 2>update.out &&
493 test_i18ngrep "not initialized" update.out &&
494 test_must_fail git rev-parse --resolve-git-dir ../init/.git &&
496 git submodule update --init ../init
498 git rev-parse --resolve-git-dir init/.git
501 test_expect_success 'do not add files from a submodule' '
504 test_must_fail git add init/a
508 test_expect_success 'gracefully add/reset submodule with a trailing slash' '
511 git commit -m "commit subproject" init &&
515 git diff --exit-code --cached init &&
517 git commit -m update a >/dev/null &&
518 git rev-parse HEAD) &&
520 test_must_fail git diff --exit-code --cached init &&
521 test $commit = $(git ls-files --stage |
522 sed -n "s/^160000 \([^ ]*\).*/\1/p") &&
524 git diff --exit-code --cached init
528 test_expect_success 'ls-files gracefully handles trailing slash' '
530 test "init" = "$(git ls-files init/)"
534 test_expect_success 'moving to a commit without submodule does not leave empty dir' '
538 git checkout initial &&
543 test_expect_success 'submodule <invalid-subcommand> fails' '
544 test_must_fail git submodule no-such-subcommand
547 test_expect_success 'add submodules without specifying an explicit path' '
554 git commit -m "repo commit 1"
556 git clone --bare repo/ bare.git &&
559 git submodule add "$submodurl/repo" &&
560 git config -f .gitmodules submodule.repo.path repo &&
561 git submodule add "$submodurl/bare.git" &&
562 git config -f .gitmodules submodule.bare.path bare
566 test_expect_success 'add should fail when path is used by a file' '
570 test_must_fail git submodule add "$submodurl/repo" file
574 test_expect_success 'add should fail when path is used by an existing directory' '
578 test_must_fail git submodule add "$submodurl/repo" empty-dir
582 test_expect_success 'use superproject as upstream when path is relative and no url is set there' '
585 git submodule add ../repo relative &&
586 test "$(git config -f .gitmodules submodule.relative.url)" = ../repo &&
587 git submodule sync relative &&
588 test "$(git config submodule.relative.url)" = "$submodurl/repo"
592 test_expect_success 'set up for relative path tests' '
604 git config -f .gitmodules submodule.sub.path sub &&
605 git config -f .gitmodules submodule.sub.url ../subrepo &&
606 cp .git/config pristine-.git-config &&
607 cp .gitmodules pristine-.gitmodules
611 test_expect_success '../subrepo works with URL - ssh://hostname/repo' '
614 cp pristine-.git-config .git/config &&
615 cp pristine-.gitmodules .gitmodules &&
616 git config remote.origin.url ssh://hostname/repo &&
617 git submodule init &&
618 test "$(git config submodule.sub.url)" = ssh://hostname/subrepo
622 test_expect_success '../subrepo works with port-qualified URL - ssh://hostname:22/repo' '
625 cp pristine-.git-config .git/config &&
626 cp pristine-.gitmodules .gitmodules &&
627 git config remote.origin.url ssh://hostname:22/repo &&
628 git submodule init &&
629 test "$(git config submodule.sub.url)" = ssh://hostname:22/subrepo
633 # About the choice of the path in the next test:
634 # - double-slash side-steps path mangling issues on Windows
635 # - it is still an absolute local path
636 # - there cannot be a server with a blank in its name just in case the
637 # path is used erroneously to access a //server/share style path
638 test_expect_success '../subrepo path works with local path - //somewhere else/repo' '
641 cp pristine-.git-config .git/config &&
642 cp pristine-.gitmodules .gitmodules &&
643 git config remote.origin.url "//somewhere else/repo" &&
644 git submodule init &&
645 test "$(git config submodule.sub.url)" = "//somewhere else/subrepo"
649 test_expect_success '../subrepo works with file URL - file:///tmp/repo' '
652 cp pristine-.git-config .git/config &&
653 cp pristine-.gitmodules .gitmodules &&
654 git config remote.origin.url file:///tmp/repo &&
655 git submodule init &&
656 test "$(git config submodule.sub.url)" = file:///tmp/subrepo
660 test_expect_success '../subrepo works with helper URL- helper:://hostname/repo' '
663 cp pristine-.git-config .git/config &&
664 cp pristine-.gitmodules .gitmodules &&
665 git config remote.origin.url helper:://hostname/repo &&
666 git submodule init &&
667 test "$(git config submodule.sub.url)" = helper:://hostname/subrepo
671 test_expect_success '../subrepo works with scp-style URL - user@host:repo' '
674 cp pristine-.git-config .git/config &&
675 git config remote.origin.url user@host:repo &&
676 git submodule init &&
677 test "$(git config submodule.sub.url)" = user@host:subrepo
681 test_expect_success '../subrepo works with scp-style URL - user@host:path/to/repo' '
684 cp pristine-.git-config .git/config &&
685 cp pristine-.gitmodules .gitmodules &&
686 git config remote.origin.url user@host:path/to/repo &&
687 git submodule init &&
688 test "$(git config submodule.sub.url)" = user@host:path/to/subrepo
692 test_expect_success '../subrepo works with relative local path - foo' '
695 cp pristine-.git-config .git/config &&
696 cp pristine-.gitmodules .gitmodules &&
697 git config remote.origin.url foo &&
698 # actual: fails with an error
699 git submodule init &&
700 test "$(git config submodule.sub.url)" = subrepo
704 test_expect_success '../subrepo works with relative local path - foo/bar' '
707 cp pristine-.git-config .git/config &&
708 cp pristine-.gitmodules .gitmodules &&
709 git config remote.origin.url foo/bar &&
710 git submodule init &&
711 test "$(git config submodule.sub.url)" = foo/subrepo
715 test_expect_success '../subrepo works with relative local path - ./foo' '
718 cp pristine-.git-config .git/config &&
719 cp pristine-.gitmodules .gitmodules &&
720 git config remote.origin.url ./foo &&
721 git submodule init &&
722 test "$(git config submodule.sub.url)" = subrepo
726 test_expect_success '../subrepo works with relative local path - ./foo/bar' '
729 cp pristine-.git-config .git/config &&
730 cp pristine-.gitmodules .gitmodules &&
731 git config remote.origin.url ./foo/bar &&
732 git submodule init &&
733 test "$(git config submodule.sub.url)" = foo/subrepo
737 test_expect_success '../subrepo works with relative local path - ../foo' '
740 cp pristine-.git-config .git/config &&
741 cp pristine-.gitmodules .gitmodules &&
742 git config remote.origin.url ../foo &&
743 git submodule init &&
744 test "$(git config submodule.sub.url)" = ../subrepo
748 test_expect_success '../subrepo works with relative local path - ../foo/bar' '
751 cp pristine-.git-config .git/config &&
752 cp pristine-.gitmodules .gitmodules &&
753 git config remote.origin.url ../foo/bar &&
754 git submodule init &&
755 test "$(git config submodule.sub.url)" = ../foo/subrepo
759 test_expect_success '../bar/a/b/c works with relative local path - ../foo/bar.git' '
762 cp pristine-.git-config .git/config &&
763 cp pristine-.gitmodules .gitmodules &&
765 (cd a/b/c; git init) &&
766 git config remote.origin.url ../foo/bar.git &&
767 git submodule add ../bar/a/b/c ./a/b/c &&
768 git submodule init &&
769 test "$(git config submodule.a/b/c.url)" = ../foo/bar/a/b/c
773 test_expect_success 'moving the superproject does not break submodules' '
776 git submodule status >expect
778 mv addtest addtest2 &&
781 git submodule status >actual &&
782 test_cmp expect actual
786 test_expect_success 'submodule add --name allows to replace a submodule with another at the same path' '
791 echo "$submodurl/repo" >expect &&
792 git config remote.origin.url >actual &&
793 test_cmp expect actual &&
794 echo "gitdir: ../.git/modules/repo" >expect &&
799 git submodule add -q --name repo_new "$submodurl/bare.git" repo >actual &&
800 test_must_be_empty actual &&
801 echo "gitdir: ../.git/modules/submod" >expect &&
802 test_cmp expect submod/.git &&
805 echo "$submodurl/bare.git" >expect &&
806 git config remote.origin.url >actual &&
807 test_cmp expect actual &&
808 echo "gitdir: ../.git/modules/repo_new" >expect &&
811 echo "repo" >expect &&
812 test_must_fail git config -f .gitmodules submodule.repo.path &&
813 git config -f .gitmodules submodule.repo_new.path >actual &&
814 test_cmp expect actual&&
815 echo "$submodurl/repo" >expect &&
816 test_must_fail git config -f .gitmodules submodule.repo.url &&
817 echo "$submodurl/bare.git" >expect &&
818 git config -f .gitmodules submodule.repo_new.url >actual &&
819 test_cmp expect actual &&
820 echo "$submodurl/repo" >expect &&
821 git config submodule.repo.url >actual &&
822 test_cmp expect actual &&
823 echo "$submodurl/bare.git" >expect &&
824 git config submodule.repo_new.url >actual &&
825 test_cmp expect actual
829 test_expect_success 'recursive relative submodules stay relative' '
830 test_when_finished "rm -rf super clone2 subsub sub3" &&
837 git commit -m "initial commit"
845 git commit -m "initial commit" &&
846 git submodule add ../subsub dirdir/subsub &&
847 git commit -m "add submodule subsub"
855 git commit -m "initial commit" &&
856 git submodule add ../sub3 &&
857 git commit -m "add submodule sub"
859 git clone super clone2 &&
862 git submodule update --init --recursive &&
863 echo "gitdir: ../.git/modules/sub3" >./sub3/.git_expect &&
864 echo "gitdir: ../../../.git/modules/sub3/modules/dirdir/subsub" >./sub3/dirdir/subsub/.git_expect
866 test_cmp clone2/sub3/.git_expect clone2/sub3/.git &&
867 test_cmp clone2/sub3/dirdir/subsub/.git_expect clone2/sub3/dirdir/subsub/.git
870 test_expect_success 'submodule add with an existing name fails unless forced' '
875 test_must_fail git submodule add -q --name repo_new "$submodurl/repo.git" repo &&
877 test_must_fail git config -f .gitmodules submodule.repo_new.path &&
878 test_must_fail git config -f .gitmodules submodule.repo_new.url &&
879 echo "$submodurl/bare.git" >expect &&
880 git config submodule.repo_new.url >actual &&
881 test_cmp expect actual &&
882 git submodule add -f -q --name repo_new "$submodurl/repo.git" repo &&
884 echo "repo" >expect &&
885 git config -f .gitmodules submodule.repo_new.path >actual &&
886 test_cmp expect actual&&
887 echo "$submodurl/repo.git" >expect &&
888 git config -f .gitmodules submodule.repo_new.url >actual &&
889 test_cmp expect actual &&
890 echo "$submodurl/repo.git" >expect &&
891 git config submodule.repo_new.url >actual &&
892 test_cmp expect actual
896 test_expect_success 'set up a second submodule' '
897 git submodule add ./init2 example2 &&
898 git commit -m "submodule example2 added"
901 test_expect_success 'submodule deinit works on repository without submodules' '
902 test_when_finished "rm -rf newdirectory" &&
903 mkdir newdirectory &&
909 git commit -m "repo should not be empty"
910 git submodule deinit .
914 test_expect_success 'submodule deinit should remove the whole submodule section from .git/config' '
915 git config submodule.example.foo bar &&
916 git config submodule.example2.frotz nitfol &&
917 git submodule deinit init &&
918 test -z "$(git config --get-regexp "submodule\.example\.")" &&
919 test -n "$(git config --get-regexp "submodule\.example2\.")" &&
920 test -f example2/.git &&
924 test_expect_success 'submodule deinit from subdirectory' '
925 git submodule update --init &&
926 git config submodule.example.foo bar &&
930 git submodule deinit ../init >../output
932 grep "\\.\\./init" output &&
933 test -z "$(git config --get-regexp "submodule\.example\.")" &&
934 test -n "$(git config --get-regexp "submodule\.example2\.")" &&
935 test -f example2/.git &&
939 test_expect_success 'submodule deinit . deinits all initialized submodules' '
940 git submodule update --init &&
941 git config submodule.example.foo bar &&
942 git config submodule.example2.frotz nitfol &&
943 test_must_fail git submodule deinit &&
944 git submodule deinit . >actual &&
945 test -z "$(git config --get-regexp "submodule\.example\.")" &&
946 test -z "$(git config --get-regexp "submodule\.example2\.")" &&
947 test_i18ngrep "Cleared directory .init" actual &&
948 test_i18ngrep "Cleared directory .example2" actual &&
952 test_expect_success 'submodule deinit deinits a submodule when its work tree is missing or empty' '
953 git submodule update --init &&
954 rm -rf init example2/* example2/.git &&
955 git submodule deinit init example2 >actual &&
956 test -z "$(git config --get-regexp "submodule\.example\.")" &&
957 test -z "$(git config --get-regexp "submodule\.example2\.")" &&
958 test_i18ngrep ! "Cleared directory .init" actual &&
959 test_i18ngrep "Cleared directory .example2" actual &&
963 test_expect_success 'submodule deinit fails when the submodule contains modifications unless forced' '
964 git submodule update --init &&
966 test_must_fail git submodule deinit init &&
967 test -n "$(git config --get-regexp "submodule\.example\.")" &&
968 test -f example2/.git &&
969 git submodule deinit -f init >actual &&
970 test -z "$(git config --get-regexp "submodule\.example\.")" &&
971 test_i18ngrep "Cleared directory .init" actual &&
975 test_expect_success 'submodule deinit fails when the submodule contains untracked files unless forced' '
976 git submodule update --init &&
977 echo X >>init/untracked &&
978 test_must_fail git submodule deinit init &&
979 test -n "$(git config --get-regexp "submodule\.example\.")" &&
980 test -f example2/.git &&
981 git submodule deinit -f init >actual &&
982 test -z "$(git config --get-regexp "submodule\.example\.")" &&
983 test_i18ngrep "Cleared directory .init" actual &&
987 test_expect_success 'submodule deinit fails when the submodule HEAD does not match unless forced' '
988 git submodule update --init &&
993 test_must_fail git submodule deinit init &&
994 test -n "$(git config --get-regexp "submodule\.example\.")" &&
995 test -f example2/.git &&
996 git submodule deinit -f init >actual &&
997 test -z "$(git config --get-regexp "submodule\.example\.")" &&
998 test_i18ngrep "Cleared directory .init" actual &&
1002 test_expect_success 'submodule deinit is silent when used on an uninitialized submodule' '
1003 git submodule update --init &&
1004 git submodule deinit init >actual &&
1005 test_i18ngrep "Submodule .example. (.*) unregistered for path .init" actual &&
1006 test_i18ngrep "Cleared directory .init" actual &&
1007 git submodule deinit init >actual &&
1008 test_i18ngrep ! "Submodule .example. (.*) unregistered for path .init" actual &&
1009 test_i18ngrep "Cleared directory .init" actual &&
1010 git submodule deinit . >actual &&
1011 test_i18ngrep ! "Submodule .example. (.*) unregistered for path .init" actual &&
1012 test_i18ngrep "Submodule .example2. (.*) unregistered for path .example2" actual &&
1013 test_i18ngrep "Cleared directory .init" actual &&
1014 git submodule deinit . >actual &&
1015 test_i18ngrep ! "Submodule .example. (.*) unregistered for path .init" actual &&
1016 test_i18ngrep ! "Submodule .example2. (.*) unregistered for path .example2" actual &&
1017 test_i18ngrep "Cleared directory .init" actual &&
1021 test_expect_success 'submodule deinit fails when submodule has a .git directory even when forced' '
1022 git submodule update --init &&
1026 cp -R ../.git/modules/example .git &&
1027 GIT_WORK_TREE=. git config --unset core.worktree
1029 test_must_fail git submodule deinit init &&
1030 test_must_fail git submodule deinit -f init &&
1031 test -d init/.git &&
1032 test -n "$(git config --get-regexp "submodule\.example\.")"
1035 test_expect_success 'submodule with UTF-8 name' '
1036 svname=$(printf "\303\245 \303\244\303\266") &&
1043 git commit -m "init sub"
1045 git submodule add ./"$svname" &&
1046 git submodule >&2 &&
1047 test -n "$(git submodule | grep "$svname")"
1050 test_expect_success 'submodule add clone shallow submodule' '
1056 git submodule add --depth=1 file://"$pwd"/example2 submodule &&
1059 test 1 = $(git log --oneline | wc -l)
1064 test_expect_success 'submodule helper list is not confused by common prefixes' '
1069 echo hi >testfile2 &&
1071 git commit -m "test1"
1077 echo hello >testfile1 &&
1079 git commit -m "test2"
1081 git submodule add /dir1/b dir1/b &&
1082 git submodule add /dir2/b dir2/b &&
1083 git commit -m "first submodule commit" &&
1084 git submodule--helper list dir1/b |cut -c51- >actual &&
1085 echo "dir1/b" >expect &&
1086 test_cmp expect actual