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 'submodule deinit works on empty repository' '
15 git submodule deinit --all
18 test_expect_success 'setup - initial commit' '
21 git commit -m "initial commit" &&
25 test_expect_success 'configuration parsing' '
26 test_when_finished "rm -f .gitmodules" &&
27 cat >.gitmodules <<-\EOF &&
32 test_must_fail git status
35 test_expect_success 'setup - repository in init subdirectory' '
42 git commit -m "submodule commit 1" &&
43 git tag -a -m "rev-1" rev-1
47 test_expect_success 'setup - commit with gitlink' '
51 git commit -m "super commit 1"
54 test_expect_success 'setup - hide init subdirectory' '
58 test_expect_success 'setup - repository to add submodules to' '
60 git init addtest-ignore
63 # The 'submodule add' tests need some repository to add as a submodule.
64 # The trash directory is a good one as any. We need to canonicalize
65 # the name, though, as some tests compare it to the absolute path git
66 # generates, which will expand symbolic links.
70 git for-each-ref --format='%(refname)' 'refs/heads/*'
79 listbranches >"$dotdot/heads" &&
80 { git symbolic-ref HEAD || :; } >"$dotdot/head" &&
81 git rev-parse HEAD >"$dotdot/head-sha1" &&
82 git update-index --refresh &&
83 git diff-files --exit-code &&
84 git clean -n -d -x >"$dotdot/untracked"
88 test_expect_success 'submodule add' '
89 echo "refs/heads/master" >expect &&
94 git submodule add -q "$submodurl" submod >actual &&
95 test_must_be_empty actual &&
96 echo "gitdir: ../.git/modules/submod" >expect &&
97 test_cmp expect submod/.git &&
100 git config core.worktree >actual &&
101 echo "../../../submod" >expect &&
102 test_cmp expect actual &&
108 rm -f heads head untracked &&
109 inspect addtest/submod ../.. &&
110 test_cmp expect heads &&
111 test_cmp expect head &&
112 test_cmp empty untracked
115 test_expect_success 'submodule add to .gitignored path fails' '
118 cat <<-\EOF >expect &&
119 The following path is ignored by one of your .gitignore files:
121 Use -f if you really want to add it.
123 # Does not use test_commit due to the ignore
124 echo "*" > .gitignore &&
125 git add --force .gitignore &&
126 git commit -m"Ignore everything" &&
127 ! git submodule add "$submodurl" submod >actual 2>&1 &&
128 test_i18ncmp expect actual
132 test_expect_success 'submodule add to .gitignored path with --force' '
135 git submodule add --force "$submodurl" submod
139 test_expect_success 'submodule add --branch' '
140 echo "refs/heads/initial" >expect-head &&
141 cat <<-\EOF >expect-heads &&
149 git submodule add -b initial "$submodurl" submod-branch &&
150 test "initial" = "$(git config -f .gitmodules submodule.submod-branch.branch)" &&
154 rm -f heads head untracked &&
155 inspect addtest/submod-branch ../.. &&
156 test_cmp expect-heads heads &&
157 test_cmp expect-head head &&
158 test_cmp empty untracked
161 test_expect_success 'submodule add with ./ in path' '
162 echo "refs/heads/master" >expect &&
167 git submodule add "$submodurl" ././dotsubmod/./frotz/./ &&
171 rm -f heads head untracked &&
172 inspect addtest/dotsubmod/frotz ../../.. &&
173 test_cmp expect heads &&
174 test_cmp expect head &&
175 test_cmp empty untracked
178 test_expect_success 'submodule add with /././ in path' '
179 echo "refs/heads/master" >expect &&
184 git submodule add "$submodurl" dotslashdotsubmod/././frotz/./ &&
188 rm -f heads head untracked &&
189 inspect addtest/dotslashdotsubmod/frotz ../../.. &&
190 test_cmp expect heads &&
191 test_cmp expect head &&
192 test_cmp empty untracked
195 test_expect_success 'submodule add with // in path' '
196 echo "refs/heads/master" >expect &&
201 git submodule add "$submodurl" slashslashsubmod///frotz// &&
205 rm -f heads head untracked &&
206 inspect addtest/slashslashsubmod/frotz ../../.. &&
207 test_cmp expect heads &&
208 test_cmp expect head &&
209 test_cmp empty untracked
212 test_expect_success 'submodule add with /.. in path' '
213 echo "refs/heads/master" >expect &&
218 git submodule add "$submodurl" dotdotsubmod/../realsubmod/frotz/.. &&
222 rm -f heads head untracked &&
223 inspect addtest/realsubmod ../.. &&
224 test_cmp expect heads &&
225 test_cmp expect head &&
226 test_cmp empty untracked
229 test_expect_success 'submodule add with ./, /.. and // in path' '
230 echo "refs/heads/master" >expect &&
235 git submodule add "$submodurl" dot/dotslashsubmod/./../..////realsubmod2/a/b/c/d/../../../../frotz//.. &&
239 rm -f heads head untracked &&
240 inspect addtest/realsubmod2 ../.. &&
241 test_cmp expect heads &&
242 test_cmp expect head &&
243 test_cmp empty untracked
246 test_expect_success 'submodule add in subdirectory' '
247 echo "refs/heads/master" >expect &&
253 git submodule add "$submodurl" ../realsubmod3 &&
257 rm -f heads head untracked &&
258 inspect addtest/realsubmod3 ../.. &&
259 test_cmp expect heads &&
260 test_cmp expect head &&
261 test_cmp empty untracked
264 test_expect_success 'submodule add in subdirectory with relative path should fail' '
267 test_must_fail git submodule add ../../ submod3 2>../../output.err
269 test_i18ngrep toplevel output.err
272 test_expect_success 'setup - add an example entry to .gitmodules' '
273 git config --file=.gitmodules submodule.example.url git://example.com/init.git
276 test_expect_success 'status should fail for unmapped paths' '
277 test_must_fail git submodule status
280 test_expect_success 'setup - map path in .gitmodules' '
281 cat <<\EOF >expect &&
282 [submodule "example"]
283 url = git://example.com/init.git
287 git config --file=.gitmodules submodule.example.path init &&
289 test_cmp expect .gitmodules
292 test_expect_success 'status should only print one line' '
293 git submodule status >lines &&
294 test_line_count = 1 lines
297 test_expect_success 'setup - fetch commit name from submodule' '
298 rev1=$(cd .subrepo && git rev-parse HEAD) &&
299 printf "rev1: %s\n" "$rev1" &&
303 test_expect_success 'status should initially be "missing"' '
304 git submodule status >lines &&
308 test_expect_success 'init should register submodule url in .git/config' '
309 echo git://example.com/init.git >expect &&
311 git submodule init &&
312 git config submodule.example.url >url &&
313 git config submodule.example.url ./.subrepo &&
318 test_failure_with_unknown_submodule () {
319 test_must_fail git submodule $1 no-such-submodule 2>output.err &&
320 grep "^error: .*no-such-submodule" output.err
323 test_expect_success 'init should fail with unknown submodule' '
324 test_failure_with_unknown_submodule init
327 test_expect_success 'update should fail with unknown submodule' '
328 test_failure_with_unknown_submodule update
331 test_expect_success 'status should fail with unknown submodule' '
332 test_failure_with_unknown_submodule status
335 test_expect_success 'sync should fail with unknown submodule' '
336 test_failure_with_unknown_submodule sync
339 test_expect_success 'update should fail when path is used by a file' '
340 echo hello >expect &&
342 echo "hello" >init &&
343 test_must_fail git submodule update &&
348 test_expect_success 'update should fail when path is used by a nonempty directory' '
349 echo hello >expect &&
353 echo "hello" >init/a &&
355 test_must_fail git submodule update &&
357 test_cmp expect init/a
360 test_expect_success 'update should work when path is an empty dir' '
363 echo "$rev1" >expect &&
366 git submodule update -q >update.out &&
367 test_must_be_empty update.out &&
370 test_cmp expect head-sha1
373 test_expect_success 'status should be "up-to-date" after update' '
374 git submodule status >list &&
378 test_expect_success 'status "up-to-date" from subdirectory' '
382 git submodule status >../list
384 grep "^ $rev1" list &&
385 grep "\\.\\./init" list
388 test_expect_success 'status "up-to-date" from subdirectory with path' '
392 git submodule status ../init >../list
394 grep "^ $rev1" list &&
395 grep "\\.\\./init" list
398 test_expect_success 'status should be "modified" after submodule commit' '
403 git commit -m "submodule commit 2"
406 rev2=$(cd init && git rev-parse HEAD) &&
408 git submodule status >list &&
413 test_expect_success 'the --cached sha1 should be rev1' '
414 git submodule --cached status >list &&
418 test_expect_success 'git diff should report the SHA1 of the new submodule commit' '
420 grep "^+Subproject commit $rev2" diff
423 test_expect_success 'update should checkout rev1' '
425 echo "$rev1" >expect &&
427 git submodule update init &&
430 test_cmp expect head-sha1
433 test_expect_success 'status should be "up-to-date" after update' '
434 git submodule status >list &&
438 test_expect_success 'checkout superproject with subproject already present' '
439 git checkout initial &&
443 test_expect_success 'apply submodule diff' '
451 git commit -m "change subproject"
453 git update-index --add init &&
454 git commit -m "change init" &&
455 git format-patch -1 --stdout >P.diff &&
456 git checkout second &&
457 git apply --index P.diff &&
459 git diff --cached master >staged &&
460 test_cmp empty staged
463 test_expect_success 'update --init' '
465 git config -f .gitmodules submodule.example.url "$(pwd)/init2" &&
466 git config --remove-section submodule.example &&
467 test_must_fail git config submodule.example.url &&
469 git submodule update init > update.out &&
471 test_i18ngrep "not initialized" update.out &&
472 test_must_fail git rev-parse --resolve-git-dir init/.git &&
474 git submodule update --init init &&
475 git rev-parse --resolve-git-dir init/.git
478 test_expect_success 'update --init from subdirectory' '
480 git config -f .gitmodules submodule.example.url "$(pwd)/init2" &&
481 git config --remove-section submodule.example &&
482 test_must_fail git config submodule.example.url &&
487 git submodule update ../init >update.out &&
489 test_i18ngrep "not initialized" update.out &&
490 test_must_fail git rev-parse --resolve-git-dir ../init/.git &&
492 git submodule update --init ../init
494 git rev-parse --resolve-git-dir init/.git
497 test_expect_success 'do not add files from a submodule' '
500 test_must_fail git add init/a
504 test_expect_success 'gracefully add/reset submodule with a trailing slash' '
507 git commit -m "commit subproject" init &&
511 git diff --exit-code --cached init &&
513 git commit -m update a >/dev/null &&
514 git rev-parse HEAD) &&
516 test_must_fail git diff --exit-code --cached init &&
517 test $commit = $(git ls-files --stage |
518 sed -n "s/^160000 \([^ ]*\).*/\1/p") &&
520 git diff --exit-code --cached init
524 test_expect_success 'ls-files gracefully handles trailing slash' '
526 test "init" = "$(git ls-files init/)"
530 test_expect_success 'moving to a commit without submodule does not leave empty dir' '
534 git checkout initial &&
539 test_expect_success 'submodule <invalid-subcommand> fails' '
540 test_must_fail git submodule no-such-subcommand
543 test_expect_success 'add submodules without specifying an explicit path' '
550 git commit -m "repo commit 1"
552 git clone --bare repo/ bare.git &&
555 git submodule add "$submodurl/repo" &&
556 git config -f .gitmodules submodule.repo.path repo &&
557 git submodule add "$submodurl/bare.git" &&
558 git config -f .gitmodules submodule.bare.path bare
562 test_expect_success 'add should fail when path is used by a file' '
566 test_must_fail git submodule add "$submodurl/repo" file
570 test_expect_success 'add should fail when path is used by an existing directory' '
574 test_must_fail git submodule add "$submodurl/repo" empty-dir
578 test_expect_success 'use superproject as upstream when path is relative and no url is set there' '
581 git submodule add ../repo relative &&
582 test "$(git config -f .gitmodules submodule.relative.url)" = ../repo &&
583 git submodule sync relative &&
584 test "$(git config submodule.relative.url)" = "$submodurl/repo"
588 test_expect_success 'set up for relative path tests' '
600 git config -f .gitmodules submodule.sub.path sub &&
601 git config -f .gitmodules submodule.sub.url ../subrepo &&
602 cp .git/config pristine-.git-config &&
603 cp .gitmodules pristine-.gitmodules
607 test_expect_success '../subrepo works with URL - ssh://hostname/repo' '
610 cp pristine-.git-config .git/config &&
611 cp pristine-.gitmodules .gitmodules &&
612 git config remote.origin.url ssh://hostname/repo &&
613 git submodule init &&
614 test "$(git config submodule.sub.url)" = ssh://hostname/subrepo
618 test_expect_success '../subrepo works with port-qualified URL - ssh://hostname:22/repo' '
621 cp pristine-.git-config .git/config &&
622 cp pristine-.gitmodules .gitmodules &&
623 git config remote.origin.url ssh://hostname:22/repo &&
624 git submodule init &&
625 test "$(git config submodule.sub.url)" = ssh://hostname:22/subrepo
629 # About the choice of the path in the next test:
630 # - double-slash side-steps path mangling issues on Windows
631 # - it is still an absolute local path
632 # - there cannot be a server with a blank in its name just in case the
633 # path is used erroneously to access a //server/share style path
634 test_expect_success '../subrepo path works with local path - //somewhere else/repo' '
637 cp pristine-.git-config .git/config &&
638 cp pristine-.gitmodules .gitmodules &&
639 git config remote.origin.url "//somewhere else/repo" &&
640 git submodule init &&
641 test "$(git config submodule.sub.url)" = "//somewhere else/subrepo"
645 test_expect_success '../subrepo works with file URL - file:///tmp/repo' '
648 cp pristine-.git-config .git/config &&
649 cp pristine-.gitmodules .gitmodules &&
650 git config remote.origin.url file:///tmp/repo &&
651 git submodule init &&
652 test "$(git config submodule.sub.url)" = file:///tmp/subrepo
656 test_expect_success '../subrepo works with helper URL- helper:://hostname/repo' '
659 cp pristine-.git-config .git/config &&
660 cp pristine-.gitmodules .gitmodules &&
661 git config remote.origin.url helper:://hostname/repo &&
662 git submodule init &&
663 test "$(git config submodule.sub.url)" = helper:://hostname/subrepo
667 test_expect_success '../subrepo works with scp-style URL - user@host:repo' '
670 cp pristine-.git-config .git/config &&
671 git config remote.origin.url user@host:repo &&
672 git submodule init &&
673 test "$(git config submodule.sub.url)" = user@host:subrepo
677 test_expect_success '../subrepo works with scp-style URL - user@host:path/to/repo' '
680 cp pristine-.git-config .git/config &&
681 cp pristine-.gitmodules .gitmodules &&
682 git config remote.origin.url user@host:path/to/repo &&
683 git submodule init &&
684 test "$(git config submodule.sub.url)" = user@host:path/to/subrepo
688 test_expect_success '../subrepo works with relative local path - foo' '
691 cp pristine-.git-config .git/config &&
692 cp pristine-.gitmodules .gitmodules &&
693 git config remote.origin.url foo &&
694 # actual: fails with an error
695 git submodule init &&
696 test "$(git config submodule.sub.url)" = subrepo
700 test_expect_success '../subrepo works with relative local path - foo/bar' '
703 cp pristine-.git-config .git/config &&
704 cp pristine-.gitmodules .gitmodules &&
705 git config remote.origin.url foo/bar &&
706 git submodule init &&
707 test "$(git config submodule.sub.url)" = foo/subrepo
711 test_expect_success '../subrepo works with relative local path - ./foo' '
714 cp pristine-.git-config .git/config &&
715 cp pristine-.gitmodules .gitmodules &&
716 git config remote.origin.url ./foo &&
717 git submodule init &&
718 test "$(git config submodule.sub.url)" = subrepo
722 test_expect_success '../subrepo works with relative local path - ./foo/bar' '
725 cp pristine-.git-config .git/config &&
726 cp pristine-.gitmodules .gitmodules &&
727 git config remote.origin.url ./foo/bar &&
728 git submodule init &&
729 test "$(git config submodule.sub.url)" = foo/subrepo
733 test_expect_success '../subrepo works with relative local path - ../foo' '
736 cp pristine-.git-config .git/config &&
737 cp pristine-.gitmodules .gitmodules &&
738 git config remote.origin.url ../foo &&
739 git submodule init &&
740 test "$(git config submodule.sub.url)" = ../subrepo
744 test_expect_success '../subrepo works with relative local path - ../foo/bar' '
747 cp pristine-.git-config .git/config &&
748 cp pristine-.gitmodules .gitmodules &&
749 git config remote.origin.url ../foo/bar &&
750 git submodule init &&
751 test "$(git config submodule.sub.url)" = ../foo/subrepo
755 test_expect_success '../bar/a/b/c works with relative local path - ../foo/bar.git' '
758 cp pristine-.git-config .git/config &&
759 cp pristine-.gitmodules .gitmodules &&
761 (cd a/b/c; git init) &&
762 git config remote.origin.url ../foo/bar.git &&
763 git submodule add ../bar/a/b/c ./a/b/c &&
764 git submodule init &&
765 test "$(git config submodule.a/b/c.url)" = ../foo/bar/a/b/c
769 test_expect_success 'moving the superproject does not break submodules' '
772 git submodule status >expect
774 mv addtest addtest2 &&
777 git submodule status >actual &&
778 test_cmp expect actual
782 test_expect_success 'submodule add --name allows to replace a submodule with another at the same path' '
787 echo "$submodurl/repo" >expect &&
788 git config remote.origin.url >actual &&
789 test_cmp expect actual &&
790 echo "gitdir: ../.git/modules/repo" >expect &&
795 git submodule add -q --name repo_new "$submodurl/bare.git" repo >actual &&
796 test_must_be_empty actual &&
797 echo "gitdir: ../.git/modules/submod" >expect &&
798 test_cmp expect submod/.git &&
801 echo "$submodurl/bare.git" >expect &&
802 git config remote.origin.url >actual &&
803 test_cmp expect actual &&
804 echo "gitdir: ../.git/modules/repo_new" >expect &&
807 echo "repo" >expect &&
808 test_must_fail git config -f .gitmodules submodule.repo.path &&
809 git config -f .gitmodules submodule.repo_new.path >actual &&
810 test_cmp expect actual&&
811 echo "$submodurl/repo" >expect &&
812 test_must_fail git config -f .gitmodules submodule.repo.url &&
813 echo "$submodurl/bare.git" >expect &&
814 git config -f .gitmodules submodule.repo_new.url >actual &&
815 test_cmp expect actual &&
816 echo "$submodurl/repo" >expect &&
817 git config submodule.repo.url >actual &&
818 test_cmp expect actual &&
819 echo "$submodurl/bare.git" >expect &&
820 git config submodule.repo_new.url >actual &&
821 test_cmp expect actual
825 test_expect_success 'recursive relative submodules stay relative' '
826 test_when_finished "rm -rf super clone2 subsub sub3" &&
833 git commit -m "initial commit"
841 git commit -m "initial commit" &&
842 git submodule add ../subsub dirdir/subsub &&
843 git commit -m "add submodule subsub"
851 git commit -m "initial commit" &&
852 git submodule add ../sub3 &&
853 git commit -m "add submodule sub"
855 git clone super clone2 &&
858 git submodule update --init --recursive &&
859 echo "gitdir: ../.git/modules/sub3" >./sub3/.git_expect &&
860 echo "gitdir: ../../../.git/modules/sub3/modules/dirdir/subsub" >./sub3/dirdir/subsub/.git_expect
862 test_cmp clone2/sub3/.git_expect clone2/sub3/.git &&
863 test_cmp clone2/sub3/dirdir/subsub/.git_expect clone2/sub3/dirdir/subsub/.git
866 test_expect_success 'submodule add with an existing name fails unless forced' '
871 test_must_fail git submodule add -q --name repo_new "$submodurl/repo.git" repo &&
873 test_must_fail git config -f .gitmodules submodule.repo_new.path &&
874 test_must_fail git config -f .gitmodules submodule.repo_new.url &&
875 echo "$submodurl/bare.git" >expect &&
876 git config submodule.repo_new.url >actual &&
877 test_cmp expect actual &&
878 git submodule add -f -q --name repo_new "$submodurl/repo.git" repo &&
880 echo "repo" >expect &&
881 git config -f .gitmodules submodule.repo_new.path >actual &&
882 test_cmp expect actual&&
883 echo "$submodurl/repo.git" >expect &&
884 git config -f .gitmodules submodule.repo_new.url >actual &&
885 test_cmp expect actual &&
886 echo "$submodurl/repo.git" >expect &&
887 git config submodule.repo_new.url >actual &&
888 test_cmp expect actual
892 test_expect_success 'set up a second submodule' '
893 git submodule add ./init2 example2 &&
894 git commit -m "submodule example2 added"
897 test_expect_success 'submodule deinit works on repository without submodules' '
898 test_when_finished "rm -rf newdirectory" &&
899 mkdir newdirectory &&
905 git commit -m "repo should not be empty"
906 git submodule deinit . &&
907 git submodule deinit --all
911 test_expect_success 'submodule deinit should remove the whole submodule section from .git/config' '
912 git config submodule.example.foo bar &&
913 git config submodule.example2.frotz nitfol &&
914 git submodule deinit init &&
915 test -z "$(git config --get-regexp "submodule\.example\.")" &&
916 test -n "$(git config --get-regexp "submodule\.example2\.")" &&
917 test -f example2/.git &&
921 test_expect_success 'submodule deinit from subdirectory' '
922 git submodule update --init &&
923 git config submodule.example.foo bar &&
927 git submodule deinit ../init >../output
929 grep "\\.\\./init" output &&
930 test -z "$(git config --get-regexp "submodule\.example\.")" &&
931 test -n "$(git config --get-regexp "submodule\.example2\.")" &&
932 test -f example2/.git &&
936 test_expect_success 'submodule deinit . deinits all initialized submodules' '
937 git submodule update --init &&
938 git config submodule.example.foo bar &&
939 git config submodule.example2.frotz nitfol &&
940 test_must_fail git submodule deinit &&
941 git submodule deinit . >actual &&
942 test -z "$(git config --get-regexp "submodule\.example\.")" &&
943 test -z "$(git config --get-regexp "submodule\.example2\.")" &&
944 test_i18ngrep "Cleared directory .init" actual &&
945 test_i18ngrep "Cleared directory .example2" actual &&
949 test_expect_success 'submodule deinit --all deinits all initialized submodules' '
950 git submodule update --init &&
951 git config submodule.example.foo bar &&
952 git config submodule.example2.frotz nitfol &&
953 test_must_fail git submodule deinit &&
954 git submodule deinit --all >actual &&
955 test -z "$(git config --get-regexp "submodule\.example\.")" &&
956 test -z "$(git config --get-regexp "submodule\.example2\.")" &&
957 test_i18ngrep "Cleared directory .init" actual &&
958 test_i18ngrep "Cleared directory .example2" actual &&
962 test_expect_success 'submodule deinit deinits a submodule when its work tree is missing or empty' '
963 git submodule update --init &&
964 rm -rf init example2/* example2/.git &&
965 git submodule deinit init example2 >actual &&
966 test -z "$(git config --get-regexp "submodule\.example\.")" &&
967 test -z "$(git config --get-regexp "submodule\.example2\.")" &&
968 test_i18ngrep ! "Cleared directory .init" actual &&
969 test_i18ngrep "Cleared directory .example2" actual &&
973 test_expect_success 'submodule deinit fails when the submodule contains modifications unless forced' '
974 git submodule update --init &&
976 test_must_fail git submodule deinit init &&
977 test -n "$(git config --get-regexp "submodule\.example\.")" &&
978 test -f example2/.git &&
979 git submodule deinit -f init >actual &&
980 test -z "$(git config --get-regexp "submodule\.example\.")" &&
981 test_i18ngrep "Cleared directory .init" actual &&
985 test_expect_success 'submodule deinit fails when the submodule contains untracked files unless forced' '
986 git submodule update --init &&
987 echo X >>init/untracked &&
988 test_must_fail git submodule deinit init &&
989 test -n "$(git config --get-regexp "submodule\.example\.")" &&
990 test -f example2/.git &&
991 git submodule deinit -f init >actual &&
992 test -z "$(git config --get-regexp "submodule\.example\.")" &&
993 test_i18ngrep "Cleared directory .init" actual &&
997 test_expect_success 'submodule deinit fails when the submodule HEAD does not match unless forced' '
998 git submodule update --init &&
1003 test_must_fail git submodule deinit init &&
1004 test -n "$(git config --get-regexp "submodule\.example\.")" &&
1005 test -f example2/.git &&
1006 git submodule deinit -f init >actual &&
1007 test -z "$(git config --get-regexp "submodule\.example\.")" &&
1008 test_i18ngrep "Cleared directory .init" actual &&
1012 test_expect_success 'submodule deinit is silent when used on an uninitialized submodule' '
1013 git submodule update --init &&
1014 git submodule deinit init >actual &&
1015 test_i18ngrep "Submodule .example. (.*) unregistered for path .init" actual &&
1016 test_i18ngrep "Cleared directory .init" actual &&
1017 git submodule deinit init >actual &&
1018 test_i18ngrep ! "Submodule .example. (.*) unregistered for path .init" actual &&
1019 test_i18ngrep "Cleared directory .init" actual &&
1020 git submodule deinit . >actual &&
1021 test_i18ngrep ! "Submodule .example. (.*) unregistered for path .init" actual &&
1022 test_i18ngrep "Submodule .example2. (.*) unregistered for path .example2" actual &&
1023 test_i18ngrep "Cleared directory .init" actual &&
1024 git submodule deinit . >actual &&
1025 test_i18ngrep ! "Submodule .example. (.*) unregistered for path .init" actual &&
1026 test_i18ngrep ! "Submodule .example2. (.*) unregistered for path .example2" actual &&
1027 test_i18ngrep "Cleared directory .init" actual &&
1028 git submodule deinit --all >actual &&
1029 test_i18ngrep ! "Submodule .example. (.*) unregistered for path .init" actual &&
1030 test_i18ngrep ! "Submodule .example2. (.*) unregistered for path .example2" actual &&
1031 test_i18ngrep "Cleared directory .init" actual &&
1035 test_expect_success 'submodule deinit fails when submodule has a .git directory even when forced' '
1036 git submodule update --init &&
1040 cp -R ../.git/modules/example .git &&
1041 GIT_WORK_TREE=. git config --unset core.worktree
1043 test_must_fail git submodule deinit init &&
1044 test_must_fail git submodule deinit -f init &&
1045 test -d init/.git &&
1046 test -n "$(git config --get-regexp "submodule\.example\.")"
1049 test_expect_success 'submodule with UTF-8 name' '
1050 svname=$(printf "\303\245 \303\244\303\266") &&
1057 git commit -m "init sub"
1059 git submodule add ./"$svname" &&
1060 git submodule >&2 &&
1061 test -n "$(git submodule | grep "$svname")"
1064 test_expect_success 'submodule add clone shallow submodule' '
1070 git submodule add --depth=1 file://"$pwd"/example2 submodule &&
1073 test 1 = $(git log --oneline | wc -l)
1078 test_expect_success 'submodule helper list is not confused by common prefixes' '
1083 echo hi >testfile2 &&
1085 git commit -m "test1"
1091 echo hello >testfile1 &&
1093 git commit -m "test2"
1095 git submodule add /dir1/b dir1/b &&
1096 git submodule add /dir2/b dir2/b &&
1097 git commit -m "first submodule commit" &&
1098 git submodule--helper list dir1/b |cut -c51- >actual &&
1099 echo "dir1/b" >expect &&
1100 test_cmp expect actual