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
'configuration parsing' '
22 test_when_finished "rm -f .gitmodules" &&
23 cat >.gitmodules <<-\EOF &&
28 test_must_fail git status
31 test_expect_success
'setup - repository in init subdirectory' '
38 git commit -m "submodule commit 1" &&
39 git tag -a -m "rev-1" rev-1
43 test_expect_success
'setup - commit with gitlink' '
47 git commit -m "super commit 1"
50 test_expect_success
'setup - hide init subdirectory' '
54 test_expect_success
'setup - repository to add submodules to' '
56 git init addtest-ignore
59 # The 'submodule add' tests need some repository to add as a submodule.
60 # The trash directory is a good one as any. We need to canonicalize
61 # the name, though, as some tests compare it to the absolute path git
62 # generates, which will expand symbolic links.
66 git for-each-ref
--format='%(refname)' 'refs/heads/*'
75 listbranches
>"$dotdot/heads" &&
76 { git symbolic-ref HEAD ||
:; } >"$dotdot/head" &&
77 git rev-parse HEAD
>"$dotdot/head-sha1" &&
78 git update-index
--refresh &&
79 git diff-files
--exit-code &&
80 git clean
-n -d -x >"$dotdot/untracked"
84 test_expect_success
'submodule add' '
85 echo "refs/heads/master" >expect &&
90 git submodule add -q "$submodurl" submod >actual &&
91 test_must_be_empty actual &&
92 echo "gitdir: ../.git/modules/submod" >expect &&
93 test_cmp expect submod/.git &&
96 git config core.worktree >actual &&
97 echo "../../../submod" >expect &&
98 test_cmp expect actual &&
104 rm -f heads head untracked &&
105 inspect addtest/submod ../.. &&
106 test_cmp expect heads &&
107 test_cmp expect head &&
108 test_cmp empty untracked
111 test_expect_success
'submodule add to .gitignored path fails' '
114 cat <<-\EOF >expect &&
115 The following path is ignored by one of your .gitignore files:
117 Use -f if you really want to add it.
119 # Does not use test_commit due to the ignore
120 echo "*" > .gitignore &&
121 git add --force .gitignore &&
122 git commit -m"Ignore everything" &&
123 ! git submodule add "$submodurl" submod >actual 2>&1 &&
124 test_i18ncmp expect actual
128 test_expect_success
'submodule add to .gitignored path with --force' '
131 git submodule add --force "$submodurl" submod
135 test_expect_success
'submodule add --branch' '
136 echo "refs/heads/initial" >expect-head &&
137 cat <<-\EOF >expect-heads &&
145 git submodule add -b initial "$submodurl" submod-branch &&
146 test "initial" = "$(git config -f .gitmodules submodule.submod-branch.branch)" &&
150 rm -f heads head untracked &&
151 inspect addtest/submod-branch ../.. &&
152 test_cmp expect-heads heads &&
153 test_cmp expect-head head &&
154 test_cmp empty untracked
157 test_expect_success
'submodule add with ./ in path' '
158 echo "refs/heads/master" >expect &&
163 git submodule add "$submodurl" ././dotsubmod/./frotz/./ &&
167 rm -f heads head untracked &&
168 inspect addtest/dotsubmod/frotz ../../.. &&
169 test_cmp expect heads &&
170 test_cmp expect head &&
171 test_cmp empty untracked
174 test_expect_success
'submodule add with /././ in path' '
175 echo "refs/heads/master" >expect &&
180 git submodule add "$submodurl" dotslashdotsubmod/././frotz/./ &&
184 rm -f heads head untracked &&
185 inspect addtest/dotslashdotsubmod/frotz ../../.. &&
186 test_cmp expect heads &&
187 test_cmp expect head &&
188 test_cmp empty untracked
191 test_expect_success
'submodule add with // in path' '
192 echo "refs/heads/master" >expect &&
197 git submodule add "$submodurl" slashslashsubmod///frotz// &&
201 rm -f heads head untracked &&
202 inspect addtest/slashslashsubmod/frotz ../../.. &&
203 test_cmp expect heads &&
204 test_cmp expect head &&
205 test_cmp empty untracked
208 test_expect_success
'submodule add with /.. in path' '
209 echo "refs/heads/master" >expect &&
214 git submodule add "$submodurl" dotdotsubmod/../realsubmod/frotz/.. &&
218 rm -f heads head untracked &&
219 inspect addtest/realsubmod ../.. &&
220 test_cmp expect heads &&
221 test_cmp expect head &&
222 test_cmp empty untracked
225 test_expect_success
'submodule add with ./, /.. and // in path' '
226 echo "refs/heads/master" >expect &&
231 git submodule add "$submodurl" dot/dotslashsubmod/./../..////realsubmod2/a/b/c/d/../../../../frotz//.. &&
235 rm -f heads head untracked &&
236 inspect addtest/realsubmod2 ../.. &&
237 test_cmp expect heads &&
238 test_cmp expect head &&
239 test_cmp empty untracked
242 test_expect_success
'submodule add in subdirectory' '
243 echo "refs/heads/master" >expect &&
249 git submodule add "$submodurl" ../realsubmod3 &&
253 rm -f heads head untracked &&
254 inspect addtest/realsubmod3 ../.. &&
255 test_cmp expect heads &&
256 test_cmp expect head &&
257 test_cmp empty untracked
260 test_expect_success
'submodule add in subdirectory with relative path should fail' '
263 test_must_fail git submodule add ../../ submod3 2>../../output.err
265 test_i18ngrep toplevel output.err
268 test_expect_success
'setup - add an example entry to .gitmodules' '
269 git config --file=.gitmodules submodule.example.url git://example.com/init.git
272 test_expect_success
'status should fail for unmapped paths' '
273 test_must_fail git submodule status
276 test_expect_success
'setup - map path in .gitmodules' '
277 cat <<\EOF >expect &&
278 [submodule "example"]
279 url = git://example.com/init.git
283 git config --file=.gitmodules submodule.example.path init &&
285 test_cmp expect .gitmodules
288 test_expect_success
'status should only print one line' '
289 git submodule status >lines &&
290 test_line_count = 1 lines
293 test_expect_success
'setup - fetch commit name from submodule' '
294 rev1=$(cd .subrepo && git rev-parse HEAD) &&
295 printf "rev1: %s\n" "$rev1" &&
299 test_expect_success
'status should initially be "missing"' '
300 git submodule status >lines &&
304 test_expect_success
'init should register submodule url in .git/config' '
305 echo git://example.com/init.git >expect &&
307 git submodule init &&
308 git config submodule.example.url >url &&
309 git config submodule.example.url ./.subrepo &&
314 test_failure_with_unknown_submodule
() {
315 test_must_fail git submodule
$1 no-such-submodule
2>output.err
&&
316 grep "^error: .*no-such-submodule" output.err
319 test_expect_success
'init should fail with unknown submodule' '
320 test_failure_with_unknown_submodule init
323 test_expect_success
'update should fail with unknown submodule' '
324 test_failure_with_unknown_submodule update
327 test_expect_success
'status should fail with unknown submodule' '
328 test_failure_with_unknown_submodule status
331 test_expect_success
'sync should fail with unknown submodule' '
332 test_failure_with_unknown_submodule sync
335 test_expect_success
'update should fail when path is used by a file' '
336 echo hello >expect &&
338 echo "hello" >init &&
339 test_must_fail git submodule update &&
344 test_expect_success
'update should fail when path is used by a nonempty directory' '
345 echo hello >expect &&
349 echo "hello" >init/a &&
351 test_must_fail git submodule update &&
353 test_cmp expect init/a
356 test_expect_success
'update should work when path is an empty dir' '
359 echo "$rev1" >expect &&
362 git submodule update -q >update.out &&
363 test_must_be_empty update.out &&
366 test_cmp expect head-sha1
369 test_expect_success
'status should be "up-to-date" after update' '
370 git submodule status >list &&
374 test_expect_success
'status "up-to-date" from subdirectory' '
378 git submodule status >../list
380 grep "^ $rev1" list &&
381 grep "\\.\\./init" list
384 test_expect_success
'status "up-to-date" from subdirectory with path' '
388 git submodule status ../init >../list
390 grep "^ $rev1" list &&
391 grep "\\.\\./init" list
394 test_expect_success
'status should be "modified" after submodule commit' '
399 git commit -m "submodule commit 2"
402 rev2=$(cd init && git rev-parse HEAD) &&
404 git submodule status >list &&
409 test_expect_success
'the --cached sha1 should be rev1' '
410 git submodule --cached status >list &&
414 test_expect_success
'git diff should report the SHA1 of the new submodule commit' '
416 grep "^+Subproject commit $rev2" diff
419 test_expect_success
'update should checkout rev1' '
421 echo "$rev1" >expect &&
423 git submodule update init &&
426 test_cmp expect head-sha1
429 test_expect_success
'status should be "up-to-date" after update' '
430 git submodule status >list &&
434 test_expect_success
'checkout superproject with subproject already present' '
435 git checkout initial &&
439 test_expect_success
'apply submodule diff' '
447 git commit -m "change subproject"
449 git update-index --add init &&
450 git commit -m "change init" &&
451 git format-patch -1 --stdout >P.diff &&
452 git checkout second &&
453 git apply --index P.diff &&
455 git diff --cached master >staged &&
456 test_cmp empty staged
459 test_expect_success
'update --init' '
461 git config -f .gitmodules submodule.example.url "$(pwd)/init2" &&
462 git config --remove-section submodule.example &&
463 test_must_fail git config submodule.example.url &&
465 git submodule update init 2> update.out &&
467 test_i18ngrep "not initialized" update.out &&
468 test_must_fail git rev-parse --resolve-git-dir init/.git &&
470 git submodule update --init init &&
471 git rev-parse --resolve-git-dir init/.git
474 test_expect_success
'update --init from subdirectory' '
476 git config -f .gitmodules submodule.example.url "$(pwd)/init2" &&
477 git config --remove-section submodule.example &&
478 test_must_fail git config submodule.example.url &&
483 git submodule update ../init 2>update.out &&
485 test_i18ngrep "not initialized" update.out &&
486 test_must_fail git rev-parse --resolve-git-dir ../init/.git &&
488 git submodule update --init ../init
490 git rev-parse --resolve-git-dir init/.git
493 test_expect_success
'do not add files from a submodule' '
496 test_must_fail git add init/a
500 test_expect_success
'gracefully add/reset submodule with a trailing slash' '
503 git commit -m "commit subproject" init &&
507 git diff --exit-code --cached init &&
509 git commit -m update a >/dev/null &&
510 git rev-parse HEAD) &&
512 test_must_fail git diff --exit-code --cached init &&
513 test $commit = $(git ls-files --stage |
514 sed -n "s/^160000 \([^ ]*\).*/\1/p") &&
516 git diff --exit-code --cached init
520 test_expect_success
'ls-files gracefully handles trailing slash' '
522 test "init" = "$(git ls-files init/)"
526 test_expect_success
'moving to a commit without submodule does not leave empty dir' '
530 git checkout initial &&
535 test_expect_success
'submodule <invalid-subcommand> fails' '
536 test_must_fail git submodule no-such-subcommand
539 test_expect_success
'add submodules without specifying an explicit path' '
546 git commit -m "repo commit 1"
548 git clone --bare repo/ bare.git &&
551 git submodule add "$submodurl/repo" &&
552 git config -f .gitmodules submodule.repo.path repo &&
553 git submodule add "$submodurl/bare.git" &&
554 git config -f .gitmodules submodule.bare.path bare
558 test_expect_success
'add should fail when path is used by a file' '
562 test_must_fail git submodule add "$submodurl/repo" file
566 test_expect_success
'add should fail when path is used by an existing directory' '
570 test_must_fail git submodule add "$submodurl/repo" empty-dir
574 test_expect_success
'use superproject as upstream when path is relative and no url is set there' '
577 git submodule add ../repo relative &&
578 test "$(git config -f .gitmodules submodule.relative.url)" = ../repo &&
579 git submodule sync relative &&
580 test "$(git config submodule.relative.url)" = "$submodurl/repo"
584 test_expect_success
'set up for relative path tests' '
596 git config -f .gitmodules submodule.sub.path sub &&
597 git config -f .gitmodules submodule.sub.url ../subrepo &&
598 cp .git/config pristine-.git-config &&
599 cp .gitmodules pristine-.gitmodules
603 test_expect_success
'../subrepo works with URL - ssh://hostname/repo' '
606 cp pristine-.git-config .git/config &&
607 cp pristine-.gitmodules .gitmodules &&
608 git config remote.origin.url ssh://hostname/repo &&
609 git submodule init &&
610 test "$(git config submodule.sub.url)" = ssh://hostname/subrepo
614 test_expect_success
'../subrepo works with port-qualified URL - ssh://hostname:22/repo' '
617 cp pristine-.git-config .git/config &&
618 cp pristine-.gitmodules .gitmodules &&
619 git config remote.origin.url ssh://hostname:22/repo &&
620 git submodule init &&
621 test "$(git config submodule.sub.url)" = ssh://hostname:22/subrepo
625 # About the choice of the path in the next test:
626 # - double-slash side-steps path mangling issues on Windows
627 # - it is still an absolute local path
628 # - there cannot be a server with a blank in its name just in case the
629 # path is used erroneously to access a //server/share style path
630 test_expect_success
'../subrepo path works with local path - //somewhere else/repo' '
633 cp pristine-.git-config .git/config &&
634 cp pristine-.gitmodules .gitmodules &&
635 git config remote.origin.url "//somewhere else/repo" &&
636 git submodule init &&
637 test "$(git config submodule.sub.url)" = "//somewhere else/subrepo"
641 test_expect_success
'../subrepo works with file URL - file:///tmp/repo' '
644 cp pristine-.git-config .git/config &&
645 cp pristine-.gitmodules .gitmodules &&
646 git config remote.origin.url file:///tmp/repo &&
647 git submodule init &&
648 test "$(git config submodule.sub.url)" = file:///tmp/subrepo
652 test_expect_success
'../subrepo works with helper URL- helper:://hostname/repo' '
655 cp pristine-.git-config .git/config &&
656 cp pristine-.gitmodules .gitmodules &&
657 git config remote.origin.url helper:://hostname/repo &&
658 git submodule init &&
659 test "$(git config submodule.sub.url)" = helper:://hostname/subrepo
663 test_expect_success
'../subrepo works with scp-style URL - user@host:repo' '
666 cp pristine-.git-config .git/config &&
667 git config remote.origin.url user@host:repo &&
668 git submodule init &&
669 test "$(git config submodule.sub.url)" = user@host:subrepo
673 test_expect_success
'../subrepo works with scp-style URL - user@host:path/to/repo' '
676 cp pristine-.git-config .git/config &&
677 cp pristine-.gitmodules .gitmodules &&
678 git config remote.origin.url user@host:path/to/repo &&
679 git submodule init &&
680 test "$(git config submodule.sub.url)" = user@host:path/to/subrepo
684 test_expect_success
'../subrepo works with relative local path - foo' '
687 cp pristine-.git-config .git/config &&
688 cp pristine-.gitmodules .gitmodules &&
689 git config remote.origin.url foo &&
690 # actual: fails with an error
691 git submodule init &&
692 test "$(git config submodule.sub.url)" = subrepo
696 test_expect_success
'../subrepo works with relative local path - foo/bar' '
699 cp pristine-.git-config .git/config &&
700 cp pristine-.gitmodules .gitmodules &&
701 git config remote.origin.url foo/bar &&
702 git submodule init &&
703 test "$(git config submodule.sub.url)" = foo/subrepo
707 test_expect_success
'../subrepo works with relative local path - ./foo' '
710 cp pristine-.git-config .git/config &&
711 cp pristine-.gitmodules .gitmodules &&
712 git config remote.origin.url ./foo &&
713 git submodule init &&
714 test "$(git config submodule.sub.url)" = subrepo
718 test_expect_success
'../subrepo works with relative local path - ./foo/bar' '
721 cp pristine-.git-config .git/config &&
722 cp pristine-.gitmodules .gitmodules &&
723 git config remote.origin.url ./foo/bar &&
724 git submodule init &&
725 test "$(git config submodule.sub.url)" = foo/subrepo
729 test_expect_success
'../subrepo works with relative local path - ../foo' '
732 cp pristine-.git-config .git/config &&
733 cp pristine-.gitmodules .gitmodules &&
734 git config remote.origin.url ../foo &&
735 git submodule init &&
736 test "$(git config submodule.sub.url)" = ../subrepo
740 test_expect_success
'../subrepo works with relative local path - ../foo/bar' '
743 cp pristine-.git-config .git/config &&
744 cp pristine-.gitmodules .gitmodules &&
745 git config remote.origin.url ../foo/bar &&
746 git submodule init &&
747 test "$(git config submodule.sub.url)" = ../foo/subrepo
751 test_expect_success
'../bar/a/b/c works with relative local path - ../foo/bar.git' '
754 cp pristine-.git-config .git/config &&
755 cp pristine-.gitmodules .gitmodules &&
757 (cd a/b/c; git init) &&
758 git config remote.origin.url ../foo/bar.git &&
759 git submodule add ../bar/a/b/c ./a/b/c &&
760 git submodule init &&
761 test "$(git config submodule.a/b/c.url)" = ../foo/bar/a/b/c
765 test_expect_success
'moving the superproject does not break submodules' '
768 git submodule status >expect
770 mv addtest addtest2 &&
773 git submodule status >actual &&
774 test_cmp expect actual
778 test_expect_success
'submodule add --name allows to replace a submodule with another at the same path' '
783 echo "$submodurl/repo" >expect &&
784 git config remote.origin.url >actual &&
785 test_cmp expect actual &&
786 echo "gitdir: ../.git/modules/repo" >expect &&
791 git submodule add -q --name repo_new "$submodurl/bare.git" repo >actual &&
792 test_must_be_empty actual &&
793 echo "gitdir: ../.git/modules/submod" >expect &&
794 test_cmp expect submod/.git &&
797 echo "$submodurl/bare.git" >expect &&
798 git config remote.origin.url >actual &&
799 test_cmp expect actual &&
800 echo "gitdir: ../.git/modules/repo_new" >expect &&
803 echo "repo" >expect &&
804 test_must_fail git config -f .gitmodules submodule.repo.path &&
805 git config -f .gitmodules submodule.repo_new.path >actual &&
806 test_cmp expect actual&&
807 echo "$submodurl/repo" >expect &&
808 test_must_fail git config -f .gitmodules submodule.repo.url &&
809 echo "$submodurl/bare.git" >expect &&
810 git config -f .gitmodules submodule.repo_new.url >actual &&
811 test_cmp expect actual &&
812 echo "$submodurl/repo" >expect &&
813 git config submodule.repo.url >actual &&
814 test_cmp expect actual &&
815 echo "$submodurl/bare.git" >expect &&
816 git config submodule.repo_new.url >actual &&
817 test_cmp expect actual
821 test_expect_success
'submodule add with an existing name fails unless forced' '
826 test_must_fail git submodule add -q --name repo_new "$submodurl/repo.git" repo &&
828 test_must_fail git config -f .gitmodules submodule.repo_new.path &&
829 test_must_fail git config -f .gitmodules submodule.repo_new.url &&
830 echo "$submodurl/bare.git" >expect &&
831 git config submodule.repo_new.url >actual &&
832 test_cmp expect actual &&
833 git submodule add -f -q --name repo_new "$submodurl/repo.git" repo &&
835 echo "repo" >expect &&
836 git config -f .gitmodules submodule.repo_new.path >actual &&
837 test_cmp expect actual&&
838 echo "$submodurl/repo.git" >expect &&
839 git config -f .gitmodules submodule.repo_new.url >actual &&
840 test_cmp expect actual &&
841 echo "$submodurl/repo.git" >expect &&
842 git config submodule.repo_new.url >actual &&
843 test_cmp expect actual
847 test_expect_success
'set up a second submodule' '
848 git submodule add ./init2 example2 &&
849 git commit -m "submodule example2 added"
852 test_expect_success
'submodule deinit works on repository without submodules' '
853 test_when_finished "rm -rf newdirectory" &&
854 mkdir newdirectory &&
860 git commit -m "repo should not be empty"
861 git submodule deinit .
865 test_expect_success
'submodule deinit should remove the whole submodule section from .git/config' '
866 git config submodule.example.foo bar &&
867 git config submodule.example2.frotz nitfol &&
868 git submodule deinit init &&
869 test -z "$(git config --get-regexp "submodule\.example\.")" &&
870 test -n "$(git config --get-regexp "submodule\.example2\.")" &&
871 test -f example2/.git &&
875 test_expect_success
'submodule deinit from subdirectory' '
876 git submodule update --init &&
877 git config submodule.example.foo bar &&
881 git submodule deinit ../init >../output
883 grep "\\.\\./init" output &&
884 test -z "$(git config --get-regexp "submodule\.example\.")" &&
885 test -n "$(git config --get-regexp "submodule\.example2\.")" &&
886 test -f example2/.git &&
890 test_expect_success
'submodule deinit . deinits all initialized submodules' '
891 git submodule update --init &&
892 git config submodule.example.foo bar &&
893 git config submodule.example2.frotz nitfol &&
894 test_must_fail git submodule deinit &&
895 git submodule deinit . >actual &&
896 test -z "$(git config --get-regexp "submodule\.example\.")" &&
897 test -z "$(git config --get-regexp "submodule\.example2\.")" &&
898 test_i18ngrep "Cleared directory .init" actual &&
899 test_i18ngrep "Cleared directory .example2" actual &&
903 test_expect_success
'submodule deinit deinits a submodule when its work tree is missing or empty' '
904 git submodule update --init &&
905 rm -rf init example2/* example2/.git &&
906 git submodule deinit init example2 >actual &&
907 test -z "$(git config --get-regexp "submodule\.example\.")" &&
908 test -z "$(git config --get-regexp "submodule\.example2\.")" &&
909 test_i18ngrep ! "Cleared directory .init" actual &&
910 test_i18ngrep "Cleared directory .example2" actual &&
914 test_expect_success
'submodule deinit fails when the submodule contains modifications unless forced' '
915 git submodule update --init &&
917 test_must_fail git submodule deinit init &&
918 test -n "$(git config --get-regexp "submodule\.example\.")" &&
919 test -f example2/.git &&
920 git submodule deinit -f init >actual &&
921 test -z "$(git config --get-regexp "submodule\.example\.")" &&
922 test_i18ngrep "Cleared directory .init" actual &&
926 test_expect_success
'submodule deinit fails when the submodule contains untracked files unless forced' '
927 git submodule update --init &&
928 echo X >>init/untracked &&
929 test_must_fail git submodule deinit init &&
930 test -n "$(git config --get-regexp "submodule\.example\.")" &&
931 test -f example2/.git &&
932 git submodule deinit -f init >actual &&
933 test -z "$(git config --get-regexp "submodule\.example\.")" &&
934 test_i18ngrep "Cleared directory .init" actual &&
938 test_expect_success
'submodule deinit fails when the submodule HEAD does not match unless forced' '
939 git submodule update --init &&
944 test_must_fail git submodule deinit init &&
945 test -n "$(git config --get-regexp "submodule\.example\.")" &&
946 test -f example2/.git &&
947 git submodule deinit -f init >actual &&
948 test -z "$(git config --get-regexp "submodule\.example\.")" &&
949 test_i18ngrep "Cleared directory .init" actual &&
953 test_expect_success
'submodule deinit is silent when used on an uninitialized submodule' '
954 git submodule update --init &&
955 git submodule deinit init >actual &&
956 test_i18ngrep "Submodule .example. (.*) unregistered for path .init" actual &&
957 test_i18ngrep "Cleared directory .init" actual &&
958 git submodule deinit init >actual &&
959 test_i18ngrep ! "Submodule .example. (.*) unregistered for path .init" actual &&
960 test_i18ngrep "Cleared directory .init" actual &&
961 git submodule deinit . >actual &&
962 test_i18ngrep ! "Submodule .example. (.*) unregistered for path .init" actual &&
963 test_i18ngrep "Submodule .example2. (.*) unregistered for path .example2" actual &&
964 test_i18ngrep "Cleared directory .init" actual &&
965 git submodule deinit . >actual &&
966 test_i18ngrep ! "Submodule .example. (.*) unregistered for path .init" actual &&
967 test_i18ngrep ! "Submodule .example2. (.*) unregistered for path .example2" actual &&
968 test_i18ngrep "Cleared directory .init" actual &&
972 test_expect_success
'submodule deinit fails when submodule has a .git directory even when forced' '
973 git submodule update --init &&
977 cp -R ../.git/modules/example .git &&
978 GIT_WORK_TREE=. git config --unset core.worktree
980 test_must_fail git submodule deinit init &&
981 test_must_fail git submodule deinit -f init &&
983 test -n "$(git config --get-regexp "submodule\.example\.")"
986 test_expect_success
'submodule with UTF-8 name' '
987 svname=$(printf "\303\245 \303\244\303\266") &&
994 git commit -m "init sub"
996 git submodule add ./"$svname" &&
998 test -n "$(git submodule | grep "$svname")"
1001 test_expect_success
'submodule add clone shallow submodule' '
1007 git submodule add --depth=1 file://"$pwd"/example2 submodule &&
1010 test 1 = $(git log --oneline | wc -l)
1015 test_expect_success
'submodule helper list is not confused by common prefixes' '
1020 echo hi >testfile2 &&
1022 git commit -m "test1"
1028 echo hello >testfile1 &&
1030 git commit -m "test2"
1032 git submodule add /dir1/b dir1/b &&
1033 git submodule add /dir2/b dir2/b &&
1034 git commit -m "first submodule commit" &&
1035 git submodule--helper list dir1/b |cut -c51- >actual &&
1036 echo "dir1/b" >expect &&
1037 test_cmp expect actual