(CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: { (SQ <'Basic porcelain support for submodules\n'> <'\n'> <'This test tries to verify basic sanity of the init, update and status\n'> <'subcommands of git submodule.\n'> ) } spids: [13] ) ] spids: [13] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(SQ <'submodule deinit works on empty repository'>)} {(SQ <'\n'> <'\tgit submodule deinit --all\n'>)} ) (C {(test_expect_success)} {(SQ <'setup - initial commit'>)} { (SQ <'\n'> <'\t>t &&\n'> <'\tgit add t &&\n'> <'\tgit commit -m "initial commit" &&\n'> <'\tgit branch initial\n'> ) } ) (C {(test_expect_success)} {(SQ <'submodule init aborts on missing .gitmodules file'>)} { (SQ <'\n'> <'\ttest_when_finished "git update-index --remove sub" &&\n'> <'\tgit update-index --add --cacheinfo 160000,$(git rev-parse HEAD),sub &&\n'> <'\t# missing the .gitmodules file here\n'> <'\ttest_must_fail git submodule init 2>actual &&\n'> <'\ttest_i18ngrep "No url found for submodule path" actual\n'> ) } ) (C {(test_expect_success)} {(SQ <'submodule update aborts on missing .gitmodules file'>)} { (SQ <'\n'> <'\ttest_when_finished "git update-index --remove sub" &&\n'> <'\tgit update-index --add --cacheinfo 160000,$(git rev-parse HEAD),sub &&\n'> <'\t# missing the .gitmodules file here\n'> <'\tgit submodule update sub 2>actual &&\n'> <'\ttest_i18ngrep "Submodule path .sub. not initialized" actual\n'> ) } ) (C {(test_expect_success)} {(SQ <'configuration parsing'>)} { (SQ <'\n'> <'\ttest_when_finished "rm -f .gitmodules" &&\n'> <'\tcat >.gitmodules <<-\\EOF &&\n'> <'\t[submodule "s"]\n'> <'\t\tpath\n'> <'\t\tignore\n'> <'\tEOF\n'> <'\ttest_must_fail git status\n'> ) } ) (C {(test_expect_success)} {(SQ <'setup - repository in init subdirectory'>)} { (SQ <'\n'> <'\tmkdir init &&\n'> <'\t(\n'> <'\t\tcd init &&\n'> <'\t\tgit init &&\n'> <'\t\techo a >a &&\n'> <'\t\tgit add a &&\n'> <'\t\tgit commit -m "submodule commit 1" &&\n'> <'\t\tgit tag -a -m "rev-1" rev-1\n'> <'\t)\n'> ) } ) (C {(test_expect_success)} {(SQ <'setup - commit with gitlink'>)} { (SQ <'\n'> <'\techo a >a &&\n'> <'\techo z >z &&\n'> <'\tgit add a init z &&\n'> <'\tgit commit -m "super commit 1"\n'> ) } ) (C {(test_expect_success)} {(SQ <'setup - hide init subdirectory'>)} {(SQ <'\n'> <'\tmv init .subrepo\n'>)} ) (C {(test_expect_success)} {(SQ <'setup - repository to add submodules to'>)} {(SQ <'\n'> <'\tgit init addtest &&\n'> <'\tgit init addtest-ignore\n'>)} ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:submodurl) op: Equal rhs: { (CommandSubPart command_list: (CommandList children:[(C {(pwd)} {(-P)})]) left_token: <Left_CommandSub '$('> spids: [177 181] ) } spids: [176] ) ] spids: [176] ) (FuncDef name: listbranches body: (BraceGroup children: [ (C {(git)} {(for-each-ref)} {(--format) (Lit_Other '=') (SQ <'%(refname)'>)} {(SQ <'refs/heads/*'>)} ) ] spids: [188] ) spids: [184 187] ) (FuncDef name: inspect body: (BraceGroup children: [ (AndOr children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:dir) op: Equal rhs: {($ VSub_Number '$1')} spids: [215] ) ] spids: [215] ) (AndOr children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:dotdot) op: Equal rhs: { (DQ (BracedVarSub token: <VSub_Number 2> suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(..)}) spids: [223 227] ) ) } spids: [221] ) ] spids: [221] ) (Subshell child: (AndOr children: [ (C {(cd)} {(DQ ($ VSub_Name '$dir'))}) (AndOr children: [ (SimpleCommand words: [{(listbranches)}] redirects: [ (Redir op_id: Redir_Great fd: 16777215 arg_word: {(DQ ($ VSub_Name '$dotdot') (/heads))} spids: [248] ) ] ) (AndOr children: [ (BraceGroup children: [ (Sentence child: (AndOr children: [ (C {(git)} {(symbolic-ref)} {(HEAD)}) (C {(Lit_Other ':')}) ] op_id: Op_DPipe ) terminator: <Op_Semi ';'> ) ] redirects: [ (Redir op_id: Redir_Great fd: 16777215 arg_word: {(DQ ($ VSub_Name '$dotdot') (/head))} spids: [272] ) ] spids: [257] ) (AndOr children: [ (SimpleCommand words: [{(git)} {(rev-parse)} {(HEAD)}] redirects: [ (Redir op_id: Redir_Great fd: 16777215 arg_word: {(DQ ($ VSub_Name '$dotdot') (/head-sha1))} spids: [287] ) ] ) (AndOr children: [ (C {(git)} {(update-index)} {(--refresh)}) (AndOr children: [ (C {(git)} {(diff-files)} {(--exit-code)}) (SimpleCommand words: [{(git)} {(clean)} {(-n)} {(-d)} {(-x)}] redirects: [ (Redir op_id: Redir_Great fd: 16777215 arg_word: {(DQ ($ VSub_Name '$dotdot') (/untracked))} spids: [324] ) ] ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) spids: [234 331] ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] spids: [212] ) spids: [208 211] ) (C {(test_expect_success)} {(SQ <'submodule add'>)} { (SQ <'\n'> <'\techo "refs/heads/master" >expect &&\n'> <'\t>empty &&\n'> <'\n'> <'\t(\n'> <'\t\tcd addtest &&\n'> <'\t\tgit submodule add -q "$submodurl" submod >actual &&\n'> <'\t\ttest_must_be_empty actual &&\n'> <'\t\techo "gitdir: ../.git/modules/submod" >expect &&\n'> <'\t\ttest_cmp expect submod/.git &&\n'> <'\t\t(\n'> <'\t\t\tcd submod &&\n'> <'\t\t\tgit config core.worktree >actual &&\n'> <'\t\t\techo "../../../submod" >expect &&\n'> <'\t\t\ttest_cmp expect actual &&\n'> <'\t\t\trm -f actual expect\n'> <'\t\t) &&\n'> <'\t\tgit submodule init\n'> <'\t) &&\n'> <'\n'> <'\trm -f heads head untracked &&\n'> <'\tinspect addtest/submod ../.. &&\n'> <'\ttest_cmp expect heads &&\n'> <'\ttest_cmp expect head &&\n'> <'\ttest_cmp empty untracked\n'> ) } ) (C {(test_expect_success)} {(SQ <'submodule add to .gitignored path fails'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd addtest-ignore &&\n'> <'\t\tcat <<-\\EOF >expect &&\n'> <'\t\tThe following path is ignored by one of your .gitignore files:\n'> <'\t\tsubmod\n'> <'\t\tUse -f if you really want to add it.\n'> <'\t\tEOF\n'> <'\t\t# Does not use test_commit due to the ignore\n'> <'\t\techo "*" > .gitignore &&\n'> <'\t\tgit add --force .gitignore &&\n'> <'\t\tgit commit -m"Ignore everything" &&\n'> <'\t\t! git submodule add "$submodurl" submod >actual 2>&1 &&\n'> <'\t\ttest_i18ncmp expect actual\n'> <'\t)\n'> ) } ) (C {(test_expect_success)} {(SQ <'submodule add to .gitignored path with --force'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd addtest-ignore &&\n'> <'\t\tgit submodule add --force "$submodurl" submod\n'> <'\t)\n'> ) } ) (C {(test_expect_success)} {(SQ <'submodule add --branch'>)} { (SQ <'\n'> <'\techo "refs/heads/initial" >expect-head &&\n'> <'\tcat <<-\\EOF >expect-heads &&\n'> <'\trefs/heads/initial\n'> <'\trefs/heads/master\n'> <'\tEOF\n'> <'\t>empty &&\n'> <'\n'> <'\t(\n'> <'\t\tcd addtest &&\n'> <'\t\tgit submodule add -b initial "$submodurl" submod-branch &&\n'> < '\t\ttest "initial" = "$(git config -f .gitmodules submodule.submod-branch.branch)" &&\n' > <'\t\tgit submodule init\n'> <'\t) &&\n'> <'\n'> <'\trm -f heads head untracked &&\n'> <'\tinspect addtest/submod-branch ../.. &&\n'> <'\ttest_cmp expect-heads heads &&\n'> <'\ttest_cmp expect-head head &&\n'> <'\ttest_cmp empty untracked\n'> ) } ) (C {(test_expect_success)} {(SQ <'submodule add with ./ in path'>)} { (SQ <'\n'> <'\techo "refs/heads/master" >expect &&\n'> <'\t>empty &&\n'> <'\n'> <'\t(\n'> <'\t\tcd addtest &&\n'> <'\t\tgit submodule add "$submodurl" ././dotsubmod/./frotz/./ &&\n'> <'\t\tgit submodule init\n'> <'\t) &&\n'> <'\n'> <'\trm -f heads head untracked &&\n'> <'\tinspect addtest/dotsubmod/frotz ../../.. &&\n'> <'\ttest_cmp expect heads &&\n'> <'\ttest_cmp expect head &&\n'> <'\ttest_cmp empty untracked\n'> ) } ) (C {(test_expect_success)} {(SQ <'submodule add with /././ in path'>)} { (SQ <'\n'> <'\techo "refs/heads/master" >expect &&\n'> <'\t>empty &&\n'> <'\n'> <'\t(\n'> <'\t\tcd addtest &&\n'> <'\t\tgit submodule add "$submodurl" dotslashdotsubmod/././frotz/./ &&\n'> <'\t\tgit submodule init\n'> <'\t) &&\n'> <'\n'> <'\trm -f heads head untracked &&\n'> <'\tinspect addtest/dotslashdotsubmod/frotz ../../.. &&\n'> <'\ttest_cmp expect heads &&\n'> <'\ttest_cmp expect head &&\n'> <'\ttest_cmp empty untracked\n'> ) } ) (C {(test_expect_success)} {(SQ <'submodule add with // in path'>)} { (SQ <'\n'> <'\techo "refs/heads/master" >expect &&\n'> <'\t>empty &&\n'> <'\n'> <'\t(\n'> <'\t\tcd addtest &&\n'> <'\t\tgit submodule add "$submodurl" slashslashsubmod///frotz// &&\n'> <'\t\tgit submodule init\n'> <'\t) &&\n'> <'\n'> <'\trm -f heads head untracked &&\n'> <'\tinspect addtest/slashslashsubmod/frotz ../../.. &&\n'> <'\ttest_cmp expect heads &&\n'> <'\ttest_cmp expect head &&\n'> <'\ttest_cmp empty untracked\n'> ) } ) (C {(test_expect_success)} {(SQ <'submodule add with /.. in path'>)} { (SQ <'\n'> <'\techo "refs/heads/master" >expect &&\n'> <'\t>empty &&\n'> <'\n'> <'\t(\n'> <'\t\tcd addtest &&\n'> <'\t\tgit submodule add "$submodurl" dotdotsubmod/../realsubmod/frotz/.. &&\n'> <'\t\tgit submodule init\n'> <'\t) &&\n'> <'\n'> <'\trm -f heads head untracked &&\n'> <'\tinspect addtest/realsubmod ../.. &&\n'> <'\ttest_cmp expect heads &&\n'> <'\ttest_cmp expect head &&\n'> <'\ttest_cmp empty untracked\n'> ) } ) (C {(test_expect_success)} {(SQ <'submodule add with ./, /.. and // in path'>)} { (SQ <'\n'> <'\techo "refs/heads/master" >expect &&\n'> <'\t>empty &&\n'> <'\n'> <'\t(\n'> <'\t\tcd addtest &&\n'> < '\t\tgit submodule add "$submodurl" dot/dotslashsubmod/./../..////realsubmod2/a/b/c/d/../../../../frotz//.. &&\n' > <'\t\tgit submodule init\n'> <'\t) &&\n'> <'\n'> <'\trm -f heads head untracked &&\n'> <'\tinspect addtest/realsubmod2 ../.. &&\n'> <'\ttest_cmp expect heads &&\n'> <'\ttest_cmp expect head &&\n'> <'\ttest_cmp empty untracked\n'> ) } ) (C {(test_expect_success)} {(SQ <'submodule add in subdirectory'>)} { (SQ <'\n'> <'\techo "refs/heads/master" >expect &&\n'> <'\t>empty &&\n'> <'\n'> <'\tmkdir addtest/sub &&\n'> <'\t(\n'> <'\t\tcd addtest/sub &&\n'> <'\t\tgit submodule add "$submodurl" ../realsubmod3 &&\n'> <'\t\tgit submodule init\n'> <'\t) &&\n'> <'\n'> <'\trm -f heads head untracked &&\n'> <'\tinspect addtest/realsubmod3 ../.. &&\n'> <'\ttest_cmp expect heads &&\n'> <'\ttest_cmp expect head &&\n'> <'\ttest_cmp empty untracked\n'> ) } ) (C {(test_expect_success)} {(SQ <'submodule add in subdirectory with relative path should fail'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd addtest/sub &&\n'> <'\t\ttest_must_fail git submodule add ../../ submod3 2>../../output.err\n'> <'\t) &&\n'> <'\ttest_i18ngrep toplevel output.err\n'> ) } ) (C {(test_expect_success)} {(SQ <'setup - add an example entry to .gitmodules'>)} { (SQ <'\n'> <'\tgit config --file=.gitmodules submodule.example.url git://example.com/init.git\n'> ) } ) (C {(test_expect_success)} {(SQ <'status should fail for unmapped paths'>)} {(SQ <'\n'> <'\ttest_must_fail git submodule status\n'>)} ) (C {(test_expect_success)} {(SQ <'setup - map path in .gitmodules'>)} { (SQ <'\n'> <'\tcat <<\\EOF >expect &&\n'> <'[submodule "example"]\n'> <'\turl = git://example.com/init.git\n'> <'\tpath = init\n'> <'EOF\n'> <'\n'> <'\tgit config --file=.gitmodules submodule.example.path init &&\n'> <'\n'> <'\ttest_cmp expect .gitmodules\n'> ) } ) (C {(test_expect_success)} {(SQ <'status should only print one line'>)} {(SQ <'\n'> <'\tgit submodule status >lines &&\n'> <'\ttest_line_count = 1 lines\n'>)} ) (C {(test_expect_success)} {(SQ <'setup - fetch commit name from submodule'>)} { (SQ <'\n'> <'\trev1=$(cd .subrepo && git rev-parse HEAD) &&\n'> <'\tprintf "rev1: %s\\n" "$rev1" &&\n'> <'\ttest -n "$rev1"\n'> ) } ) (C {(test_expect_success)} {(SQ <'status should initially be "missing"'>)} {(SQ <'\n'> <'\tgit submodule status >lines &&\n'> <'\tgrep "^-$rev1" lines\n'>)} ) (C {(test_expect_success)} {(SQ <'init should register submodule url in .git/config'>)} { (SQ <'\n'> <'\techo git://example.com/init.git >expect &&\n'> <'\n'> <'\tgit submodule init &&\n'> <'\tgit config submodule.example.url >url &&\n'> <'\tgit config submodule.example.url ./.subrepo &&\n'> <'\n'> <'\ttest_cmp expect url\n'> ) } ) (FuncDef name: test_failure_with_unknown_submodule body: (BraceGroup children: [ (AndOr children: [ (SimpleCommand words: [ {(test_must_fail)} {(git)} {(submodule)} {($ VSub_Number '$1')} {(no-such-submodule)} ] redirects: [(Redir op_id:Redir_Great fd:2 arg_word:{(output.err)} spids:[728])] ) (C {(grep)} {(DQ ('^error: .*no-such-submodule'))} {(output.err)}) ] op_id: Op_DAmp ) ] spids: [715] ) spids: [710 714] ) (C {(test_expect_success)} {(SQ <'init should fail with unknown submodule'>)} {(SQ <'\n'> <'\ttest_failure_with_unknown_submodule init\n'>)} ) (C {(test_expect_success)} {(SQ <'update should fail with unknown submodule'>)} {(SQ <'\n'> <'\ttest_failure_with_unknown_submodule update\n'>)} ) (C {(test_expect_success)} {(SQ <'status should fail with unknown submodule'>)} {(SQ <'\n'> <'\ttest_failure_with_unknown_submodule status\n'>)} ) (C {(test_expect_success)} {(SQ <'sync should fail with unknown submodule'>)} {(SQ <'\n'> <'\ttest_failure_with_unknown_submodule sync\n'>)} ) (C {(test_expect_success)} {(SQ <'update should fail when path is used by a file'>)} { (SQ <'\n'> <'\techo hello >expect &&\n'> <'\n'> <'\techo "hello" >init &&\n'> <'\ttest_must_fail git submodule update &&\n'> <'\n'> <'\ttest_cmp expect init\n'> ) } ) (C {(test_expect_success)} {(SQ <'update should fail when path is used by a nonempty directory'>)} { (SQ <'\n'> <'\techo hello >expect &&\n'> <'\n'> <'\trm -fr init &&\n'> <'\tmkdir init &&\n'> <'\techo "hello" >init/a &&\n'> <'\n'> <'\ttest_must_fail git submodule update &&\n'> <'\n'> <'\ttest_cmp expect init/a\n'> ) } ) (C {(test_expect_success)} {(SQ <'update should work when path is an empty dir'>)} { (SQ <'\n'> <'\trm -fr init &&\n'> <'\trm -f head-sha1 &&\n'> <'\techo "$rev1" >expect &&\n'> <'\n'> <'\tmkdir init &&\n'> <'\tgit submodule update -q >update.out &&\n'> <'\ttest_must_be_empty update.out &&\n'> <'\n'> <'\tinspect init &&\n'> <'\ttest_cmp expect head-sha1\n'> ) } ) (C {(test_expect_success)} {(SQ <'status should be "up-to-date" after update'>)} {(SQ <'\n'> <'\tgit submodule status >list &&\n'> <'\tgrep "^ $rev1" list\n'>)} ) (C {(test_expect_success)} {(SQ <'status "up-to-date" from subdirectory'>)} { (SQ <'\n'> <'\tmkdir -p sub &&\n'> <'\t(\n'> <'\t\tcd sub &&\n'> <'\t\tgit submodule status >../list\n'> <'\t) &&\n'> <'\tgrep "^ $rev1" list &&\n'> <'\tgrep "\\\\.\\\\./init" list\n'> ) } ) (C {(test_expect_success)} {(SQ <'status "up-to-date" from subdirectory with path'>)} { (SQ <'\n'> <'\tmkdir -p sub &&\n'> <'\t(\n'> <'\t\tcd sub &&\n'> <'\t\tgit submodule status ../init >../list\n'> <'\t) &&\n'> <'\tgrep "^ $rev1" list &&\n'> <'\tgrep "\\\\.\\\\./init" list\n'> ) } ) (C {(test_expect_success)} {(SQ <'status should be "modified" after submodule commit'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd init &&\n'> <'\t\techo b >b &&\n'> <'\t\tgit add b &&\n'> <'\t\tgit commit -m "submodule commit 2"\n'> <'\t) &&\n'> <'\n'> <'\trev2=$(cd init && git rev-parse HEAD) &&\n'> <'\ttest -n "$rev2" &&\n'> <'\tgit submodule status >list &&\n'> <'\n'> <'\tgrep "^+$rev2" list\n'> ) } ) (C {(test_expect_success)} {(SQ <'the --cached sha1 should be rev1'>)} {(SQ <'\n'> <'\tgit submodule --cached status >list &&\n'> <'\tgrep "^+$rev1" list\n'>)} ) (C {(test_expect_success)} {(SQ <'git diff should report the SHA1 of the new submodule commit'>)} {(SQ <'\n'> <'\tgit diff >diff &&\n'> <'\tgrep "^+Subproject commit $rev2" diff\n'>)} ) (C {(test_expect_success)} {(SQ <'update should checkout rev1'>)} { (SQ <'\n'> <'\trm -f head-sha1 &&\n'> <'\techo "$rev1" >expect &&\n'> <'\n'> <'\tgit submodule update init &&\n'> <'\tinspect init &&\n'> <'\n'> <'\ttest_cmp expect head-sha1\n'> ) } ) (C {(test_expect_success)} {(SQ <'status should be "up-to-date" after update'>)} {(SQ <'\n'> <'\tgit submodule status >list &&\n'> <'\tgrep "^ $rev1" list\n'>)} ) (C {(test_expect_success)} {(SQ <'checkout superproject with subproject already present'>)} {(SQ <'\n'> <'\tgit checkout initial &&\n'> <'\tgit checkout master\n'>)} ) (C {(test_expect_success)} {(SQ <'apply submodule diff'>)} { (SQ <'\n'> <'\t>empty &&\n'> <'\n'> <'\tgit branch second &&\n'> <'\t(\n'> <'\t\tcd init &&\n'> <'\t\techo s >s &&\n'> <'\t\tgit add s &&\n'> <'\t\tgit commit -m "change subproject"\n'> <'\t) &&\n'> <'\tgit update-index --add init &&\n'> <'\tgit commit -m "change init" &&\n'> <'\tgit format-patch -1 --stdout >P.diff &&\n'> <'\tgit checkout second &&\n'> <'\tgit apply --index P.diff &&\n'> <'\n'> <'\tgit diff --cached master >staged &&\n'> <'\ttest_cmp empty staged\n'> ) } ) (C {(test_expect_success)} {(SQ <'update --init'>)} { (SQ <'\n'> <'\tmv init init2 &&\n'> <'\tgit config -f .gitmodules submodule.example.url "$(pwd)/init2" &&\n'> <'\tgit config --remove-section submodule.example &&\n'> <'\ttest_must_fail git config submodule.example.url &&\n'> <'\n'> <'\tgit submodule update init 2> update.out &&\n'> <'\tcat update.out &&\n'> <'\ttest_i18ngrep "not initialized" update.out &&\n'> <'\ttest_must_fail git rev-parse --resolve-git-dir init/.git &&\n'> <'\n'> <'\tgit submodule update --init init &&\n'> <'\tgit rev-parse --resolve-git-dir init/.git\n'> ) } ) (C {(test_expect_success)} {(SQ <'update --init from subdirectory'>)} { (SQ <'\n'> <'\tmv init init2 &&\n'> <'\tgit config -f .gitmodules submodule.example.url "$(pwd)/init2" &&\n'> <'\tgit config --remove-section submodule.example &&\n'> <'\ttest_must_fail git config submodule.example.url &&\n'> <'\n'> <'\tmkdir -p sub &&\n'> <'\t(\n'> <'\t\tcd sub &&\n'> <'\t\tgit submodule update ../init 2>update.out &&\n'> <'\t\tcat update.out &&\n'> <'\t\ttest_i18ngrep "not initialized" update.out &&\n'> <'\t\ttest_must_fail git rev-parse --resolve-git-dir ../init/.git &&\n'> <'\n'> <'\t\tgit submodule update --init ../init\n'> <'\t) &&\n'> <'\tgit rev-parse --resolve-git-dir init/.git\n'> ) } ) (C {(test_expect_success)} {(SQ <'do not add files from a submodule'>)} {(SQ <'\n'> <'\n'> <'\tgit reset --hard &&\n'> <'\ttest_must_fail git add init/a\n'> <'\n'>)} ) (C {(test_expect_success)} {(SQ <'gracefully add/reset submodule with a trailing slash'>)} { (SQ <'\n'> <'\n'> <'\tgit reset --hard &&\n'> <'\tgit commit -m "commit subproject" init &&\n'> <'\t(cd init &&\n'> <'\t echo b > a) &&\n'> <'\tgit add init/ &&\n'> <'\tgit diff --exit-code --cached init &&\n'> <'\tcommit=$(cd init &&\n'> <'\t git commit -m update a >/dev/null &&\n'> <'\t git rev-parse HEAD) &&\n'> <'\tgit add init/ &&\n'> <'\ttest_must_fail git diff --exit-code --cached init &&\n'> <'\ttest $commit = $(git ls-files --stage |\n'> <'\t\tsed -n "s/^160000 \\([^ ]*\\).*/\\1/p") &&\n'> <'\tgit reset init/ &&\n'> <'\tgit diff --exit-code --cached init\n'> <'\n'> ) } ) (C {(test_expect_success)} {(SQ <'ls-files gracefully handles trailing slash'>)} {(SQ <'\n'> <'\n'> <'\ttest "init" = "$(git ls-files init/)"\n'> <'\n'>)} ) (C {(test_expect_success)} {(SQ <'moving to a commit without submodule does not leave empty dir'>)} { (SQ <'\n'> <'\trm -rf init &&\n'> <'\tmkdir init &&\n'> <'\tgit reset --hard &&\n'> <'\tgit checkout initial &&\n'> <'\ttest ! -d init &&\n'> <'\tgit checkout second\n'> ) } ) (C {(test_expect_success)} {(SQ <'submodule <invalid-subcommand> fails'>)} {(SQ <'\n'> <'\ttest_must_fail git submodule no-such-subcommand\n'>)} ) (C {(test_expect_success)} {(SQ <'add submodules without specifying an explicit path'>)} { (SQ <'\n'> <'\tmkdir repo &&\n'> <'\t(\n'> <'\t\tcd repo &&\n'> <'\t\tgit init &&\n'> <'\t\techo r >r &&\n'> <'\t\tgit add r &&\n'> <'\t\tgit commit -m "repo commit 1"\n'> <'\t) &&\n'> <'\tgit clone --bare repo/ bare.git &&\n'> <'\t(\n'> <'\t\tcd addtest &&\n'> <'\t\tgit submodule add "$submodurl/repo" &&\n'> <'\t\tgit config -f .gitmodules submodule.repo.path repo &&\n'> <'\t\tgit submodule add "$submodurl/bare.git" &&\n'> <'\t\tgit config -f .gitmodules submodule.bare.path bare\n'> <'\t)\n'> ) } ) (C {(test_expect_success)} {(SQ <'add should fail when path is used by a file'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd addtest &&\n'> <'\t\ttouch file &&\n'> <'\t\ttest_must_fail\tgit submodule add "$submodurl/repo" file\n'> <'\t)\n'> ) } ) (C {(test_expect_success)} {(SQ <'add should fail when path is used by an existing directory'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd addtest &&\n'> <'\t\tmkdir empty-dir &&\n'> <'\t\ttest_must_fail git submodule add "$submodurl/repo" empty-dir\n'> <'\t)\n'> ) } ) (C {(test_expect_success)} {(SQ <'use superproject as upstream when path is relative and no url is set there'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd addtest &&\n'> <'\t\tgit submodule add ../repo relative &&\n'> <'\t\ttest "$(git config -f .gitmodules submodule.relative.url)" = ../repo &&\n'> <'\t\tgit submodule sync relative &&\n'> <'\t\ttest "$(git config submodule.relative.url)" = "$submodurl/repo"\n'> <'\t)\n'> ) } ) (C {(test_expect_success)} {(SQ <'set up for relative path tests'>)} { (SQ <'\n'> <'\tmkdir reltest &&\n'> <'\t(\n'> <'\t\tcd reltest &&\n'> <'\t\tgit init &&\n'> <'\t\tmkdir sub &&\n'> <'\t\t(\n'> <'\t\t\tcd sub &&\n'> <'\t\t\tgit init &&\n'> <'\t\t\ttest_commit foo\n'> <'\t\t) &&\n'> <'\t\tgit add sub &&\n'> <'\t\tgit config -f .gitmodules submodule.sub.path sub &&\n'> <'\t\tgit config -f .gitmodules submodule.sub.url ../subrepo &&\n'> <'\t\tcp .git/config pristine-.git-config &&\n'> <'\t\tcp .gitmodules pristine-.gitmodules\n'> <'\t)\n'> ) } ) (C {(test_expect_success)} {(SQ <'../subrepo works with URL - ssh://hostname/repo'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd reltest &&\n'> <'\t\tcp pristine-.git-config .git/config &&\n'> <'\t\tcp pristine-.gitmodules .gitmodules &&\n'> <'\t\tgit config remote.origin.url ssh://hostname/repo &&\n'> <'\t\tgit submodule init &&\n'> <'\t\ttest "$(git config submodule.sub.url)" = ssh://hostname/subrepo\n'> <'\t)\n'> ) } ) (C {(test_expect_success)} {(SQ <'../subrepo works with port-qualified URL - ssh://hostname:22/repo'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd reltest &&\n'> <'\t\tcp pristine-.git-config .git/config &&\n'> <'\t\tcp pristine-.gitmodules .gitmodules &&\n'> <'\t\tgit config remote.origin.url ssh://hostname:22/repo &&\n'> <'\t\tgit submodule init &&\n'> <'\t\ttest "$(git config submodule.sub.url)" = ssh://hostname:22/subrepo\n'> <'\t)\n'> ) } ) (C {(test_expect_success)} {(SQ <'../subrepo path works with local path - //somewhere else/repo'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd reltest &&\n'> <'\t\tcp pristine-.git-config .git/config &&\n'> <'\t\tcp pristine-.gitmodules .gitmodules &&\n'> <'\t\tgit config remote.origin.url "//somewhere else/repo" &&\n'> <'\t\tgit submodule init &&\n'> <'\t\ttest "$(git config submodule.sub.url)" = "//somewhere else/subrepo"\n'> <'\t)\n'> ) } ) (C {(test_expect_success)} {(SQ <'../subrepo works with file URL - file:///tmp/repo'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd reltest &&\n'> <'\t\tcp pristine-.git-config .git/config &&\n'> <'\t\tcp pristine-.gitmodules .gitmodules &&\n'> <'\t\tgit config remote.origin.url file:///tmp/repo &&\n'> <'\t\tgit submodule init &&\n'> <'\t\ttest "$(git config submodule.sub.url)" = file:///tmp/subrepo\n'> <'\t)\n'> ) } ) (C {(test_expect_success)} {(SQ <'../subrepo works with helper URL- helper:://hostname/repo'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd reltest &&\n'> <'\t\tcp pristine-.git-config .git/config &&\n'> <'\t\tcp pristine-.gitmodules .gitmodules &&\n'> <'\t\tgit config remote.origin.url helper:://hostname/repo &&\n'> <'\t\tgit submodule init &&\n'> <'\t\ttest "$(git config submodule.sub.url)" = helper:://hostname/subrepo\n'> <'\t)\n'> ) } ) (C {(test_expect_success)} {(SQ <'../subrepo works with scp-style URL - user@host:repo'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd reltest &&\n'> <'\t\tcp pristine-.git-config .git/config &&\n'> <'\t\tgit config remote.origin.url user@host:repo &&\n'> <'\t\tgit submodule init &&\n'> <'\t\ttest "$(git config submodule.sub.url)" = user@host:subrepo\n'> <'\t)\n'> ) } ) (C {(test_expect_success)} {(SQ <'../subrepo works with scp-style URL - user@host:path/to/repo'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd reltest &&\n'> <'\t\tcp pristine-.git-config .git/config &&\n'> <'\t\tcp pristine-.gitmodules .gitmodules &&\n'> <'\t\tgit config remote.origin.url user@host:path/to/repo &&\n'> <'\t\tgit submodule init &&\n'> <'\t\ttest "$(git config submodule.sub.url)" = user@host:path/to/subrepo\n'> <'\t)\n'> ) } ) (C {(test_expect_success)} {(SQ <'../subrepo works with relative local path - foo'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd reltest &&\n'> <'\t\tcp pristine-.git-config .git/config &&\n'> <'\t\tcp pristine-.gitmodules .gitmodules &&\n'> <'\t\tgit config remote.origin.url foo &&\n'> <'\t\t# actual: fails with an error\n'> <'\t\tgit submodule init &&\n'> <'\t\ttest "$(git config submodule.sub.url)" = subrepo\n'> <'\t)\n'> ) } ) (C {(test_expect_success)} {(SQ <'../subrepo works with relative local path - foo/bar'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd reltest &&\n'> <'\t\tcp pristine-.git-config .git/config &&\n'> <'\t\tcp pristine-.gitmodules .gitmodules &&\n'> <'\t\tgit config remote.origin.url foo/bar &&\n'> <'\t\tgit submodule init &&\n'> <'\t\ttest "$(git config submodule.sub.url)" = foo/subrepo\n'> <'\t)\n'> ) } ) (C {(test_expect_success)} {(SQ <'../subrepo works with relative local path - ./foo'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd reltest &&\n'> <'\t\tcp pristine-.git-config .git/config &&\n'> <'\t\tcp pristine-.gitmodules .gitmodules &&\n'> <'\t\tgit config remote.origin.url ./foo &&\n'> <'\t\tgit submodule init &&\n'> <'\t\ttest "$(git config submodule.sub.url)" = subrepo\n'> <'\t)\n'> ) } ) (C {(test_expect_success)} {(SQ <'../subrepo works with relative local path - ./foo/bar'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd reltest &&\n'> <'\t\tcp pristine-.git-config .git/config &&\n'> <'\t\tcp pristine-.gitmodules .gitmodules &&\n'> <'\t\tgit config remote.origin.url ./foo/bar &&\n'> <'\t\tgit submodule init &&\n'> <'\t\ttest "$(git config submodule.sub.url)" = foo/subrepo\n'> <'\t)\n'> ) } ) (C {(test_expect_success)} {(SQ <'../subrepo works with relative local path - ../foo'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd reltest &&\n'> <'\t\tcp pristine-.git-config .git/config &&\n'> <'\t\tcp pristine-.gitmodules .gitmodules &&\n'> <'\t\tgit config remote.origin.url ../foo &&\n'> <'\t\tgit submodule init &&\n'> <'\t\ttest "$(git config submodule.sub.url)" = ../subrepo\n'> <'\t)\n'> ) } ) (C {(test_expect_success)} {(SQ <'../subrepo works with relative local path - ../foo/bar'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd reltest &&\n'> <'\t\tcp pristine-.git-config .git/config &&\n'> <'\t\tcp pristine-.gitmodules .gitmodules &&\n'> <'\t\tgit config remote.origin.url ../foo/bar &&\n'> <'\t\tgit submodule init &&\n'> <'\t\ttest "$(git config submodule.sub.url)" = ../foo/subrepo\n'> <'\t)\n'> ) } ) (C {(test_expect_success)} {(SQ <'../bar/a/b/c works with relative local path - ../foo/bar.git'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd reltest &&\n'> <'\t\tcp pristine-.git-config .git/config &&\n'> <'\t\tcp pristine-.gitmodules .gitmodules &&\n'> <'\t\tmkdir -p a/b/c &&\n'> <'\t\t(cd a/b/c; git init) &&\n'> <'\t\tgit config remote.origin.url ../foo/bar.git &&\n'> <'\t\tgit submodule add ../bar/a/b/c ./a/b/c &&\n'> <'\t\tgit submodule init &&\n'> <'\t\ttest "$(git config submodule.a/b/c.url)" = ../foo/bar/a/b/c\n'> <'\t)\n'> ) } ) (C {(test_expect_success)} {(SQ <'moving the superproject does not break submodules'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd addtest &&\n'> <'\t\tgit submodule status >expect\n'> <'\t) &&\n'> <'\tmv addtest addtest2 &&\n'> <'\t(\n'> <'\t\tcd addtest2 &&\n'> <'\t\tgit submodule status >actual &&\n'> <'\t\ttest_cmp expect actual\n'> <'\t)\n'> ) } ) (C {(test_expect_success)} {(SQ <'submodule add --name allows to replace a submodule with another at the same path'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd addtest2 &&\n'> <'\t\t(\n'> <'\t\t\tcd repo &&\n'> <'\t\t\techo "$submodurl/repo" >expect &&\n'> <'\t\t\tgit config remote.origin.url >actual &&\n'> <'\t\t\ttest_cmp expect actual &&\n'> <'\t\t\techo "gitdir: ../.git/modules/repo" >expect &&\n'> <'\t\t\ttest_cmp expect .git\n'> <'\t\t) &&\n'> <'\t\trm -rf repo &&\n'> <'\t\tgit rm repo &&\n'> <'\t\tgit submodule add -q --name repo_new "$submodurl/bare.git" repo >actual &&\n'> <'\t\ttest_must_be_empty actual &&\n'> <'\t\techo "gitdir: ../.git/modules/submod" >expect &&\n'> <'\t\ttest_cmp expect submod/.git &&\n'> <'\t\t(\n'> <'\t\t\tcd repo &&\n'> <'\t\t\techo "$submodurl/bare.git" >expect &&\n'> <'\t\t\tgit config remote.origin.url >actual &&\n'> <'\t\t\ttest_cmp expect actual &&\n'> <'\t\t\techo "gitdir: ../.git/modules/repo_new" >expect &&\n'> <'\t\t\ttest_cmp expect .git\n'> <'\t\t) &&\n'> <'\t\techo "repo" >expect &&\n'> <'\t\ttest_must_fail git config -f .gitmodules submodule.repo.path &&\n'> <'\t\tgit config -f .gitmodules submodule.repo_new.path >actual &&\n'> <'\t\ttest_cmp expect actual&&\n'> <'\t\techo "$submodurl/repo" >expect &&\n'> <'\t\ttest_must_fail git config -f .gitmodules submodule.repo.url &&\n'> <'\t\techo "$submodurl/bare.git" >expect &&\n'> <'\t\tgit config -f .gitmodules submodule.repo_new.url >actual &&\n'> <'\t\ttest_cmp expect actual &&\n'> <'\t\techo "$submodurl/repo" >expect &&\n'> <'\t\tgit config submodule.repo.url >actual &&\n'> <'\t\ttest_cmp expect actual &&\n'> <'\t\techo "$submodurl/bare.git" >expect &&\n'> <'\t\tgit config submodule.repo_new.url >actual &&\n'> <'\t\ttest_cmp expect actual\n'> <'\t)\n'> ) } ) (C {(test_expect_success)} {(SQ <'recursive relative submodules stay relative'>)} { (SQ <'\n'> <'\ttest_when_finished "rm -rf super clone2 subsub sub3" &&\n'> <'\tmkdir subsub &&\n'> <'\t(\n'> <'\t\tcd subsub &&\n'> <'\t\tgit init &&\n'> <'\t\t>t &&\n'> <'\t\tgit add t &&\n'> <'\t\tgit commit -m "initial commit"\n'> <'\t) &&\n'> <'\tmkdir sub3 &&\n'> <'\t(\n'> <'\t\tcd sub3 &&\n'> <'\t\tgit init &&\n'> <'\t\t>t &&\n'> <'\t\tgit add t &&\n'> <'\t\tgit commit -m "initial commit" &&\n'> <'\t\tgit submodule add ../subsub dirdir/subsub &&\n'> <'\t\tgit commit -m "add submodule subsub"\n'> <'\t) &&\n'> <'\tmkdir super &&\n'> <'\t(\n'> <'\t\tcd super &&\n'> <'\t\tgit init &&\n'> <'\t\t>t &&\n'> <'\t\tgit add t &&\n'> <'\t\tgit commit -m "initial commit" &&\n'> <'\t\tgit submodule add ../sub3 &&\n'> <'\t\tgit commit -m "add submodule sub"\n'> <'\t) &&\n'> <'\tgit clone super clone2 &&\n'> <'\t(\n'> <'\t\tcd clone2 &&\n'> <'\t\tgit submodule update --init --recursive &&\n'> <'\t\techo "gitdir: ../.git/modules/sub3" >./sub3/.git_expect &&\n'> < '\t\techo "gitdir: ../../../.git/modules/sub3/modules/dirdir/subsub" >./sub3/dirdir/subsub/.git_expect\n' > <'\t) &&\n'> <'\ttest_cmp clone2/sub3/.git_expect clone2/sub3/.git &&\n'> <'\ttest_cmp clone2/sub3/dirdir/subsub/.git_expect clone2/sub3/dirdir/subsub/.git\n'> ) } ) (C {(test_expect_success)} {(SQ <'submodule add with an existing name fails unless forced'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd addtest2 &&\n'> <'\t\trm -rf repo &&\n'> <'\t\tgit rm repo &&\n'> < '\t\ttest_must_fail git submodule add -q --name repo_new "$submodurl/repo.git" repo &&\n' > <'\t\ttest ! -d repo &&\n'> <'\t\ttest_must_fail git config -f .gitmodules submodule.repo_new.path &&\n'> <'\t\ttest_must_fail git config -f .gitmodules submodule.repo_new.url &&\n'> <'\t\techo "$submodurl/bare.git" >expect &&\n'> <'\t\tgit config submodule.repo_new.url >actual &&\n'> <'\t\ttest_cmp expect actual &&\n'> <'\t\tgit submodule add -f -q --name repo_new "$submodurl/repo.git" repo &&\n'> <'\t\ttest -d repo &&\n'> <'\t\techo "repo" >expect &&\n'> <'\t\tgit config -f .gitmodules submodule.repo_new.path >actual &&\n'> <'\t\ttest_cmp expect actual&&\n'> <'\t\techo "$submodurl/repo.git" >expect &&\n'> <'\t\tgit config -f .gitmodules submodule.repo_new.url >actual &&\n'> <'\t\ttest_cmp expect actual &&\n'> <'\t\techo "$submodurl/repo.git" >expect &&\n'> <'\t\tgit config submodule.repo_new.url >actual &&\n'> <'\t\ttest_cmp expect actual\n'> <'\t)\n'> ) } ) (C {(test_expect_success)} {(SQ <'set up a second submodule'>)} { (SQ <'\n'> <'\tgit submodule add ./init2 example2 &&\n'> <'\tgit commit -m "submodule example2 added"\n'> ) } ) (C {(test_expect_success)} {(SQ <'submodule deinit works on repository without submodules'>)} { (SQ <'\n'> <'\ttest_when_finished "rm -rf newdirectory" &&\n'> <'\tmkdir newdirectory &&\n'> <'\t(\n'> <'\t\tcd newdirectory &&\n'> <'\t\tgit init &&\n'> <'\t\t>file &&\n'> <'\t\tgit add file &&\n'> <'\t\tgit commit -m "repo should not be empty" &&\n'> <'\t\tgit submodule deinit . &&\n'> <'\t\tgit submodule deinit --all\n'> <'\t)\n'> ) } ) (C {(test_expect_success)} {(SQ <'submodule deinit should remove the whole submodule section from .git/config'>)} { (SQ <'\n'> <'\tgit config submodule.example.foo bar &&\n'> <'\tgit config submodule.example2.frotz nitfol &&\n'> <'\tgit submodule deinit init &&\n'> <'\ttest -z "$(git config --get-regexp "submodule\\.example\\.")" &&\n'> <'\ttest -n "$(git config --get-regexp "submodule\\.example2\\.")" &&\n'> <'\ttest -f example2/.git &&\n'> <'\trmdir init\n'> ) } ) (C {(test_expect_success)} {(SQ <'submodule deinit from subdirectory'>)} { (SQ <'\n'> <'\tgit submodule update --init &&\n'> <'\tgit config submodule.example.foo bar &&\n'> <'\tmkdir -p sub &&\n'> <'\t(\n'> <'\t\tcd sub &&\n'> <'\t\tgit submodule deinit ../init >../output\n'> <'\t) &&\n'> <'\ttest_i18ngrep "\\\\.\\\\./init" output &&\n'> <'\ttest -z "$(git config --get-regexp "submodule\\.example\\.")" &&\n'> <'\ttest -n "$(git config --get-regexp "submodule\\.example2\\.")" &&\n'> <'\ttest -f example2/.git &&\n'> <'\trmdir init\n'> ) } ) (C {(test_expect_success)} {(SQ <'submodule deinit . deinits all initialized submodules'>)} { (SQ <'\n'> <'\tgit submodule update --init &&\n'> <'\tgit config submodule.example.foo bar &&\n'> <'\tgit config submodule.example2.frotz nitfol &&\n'> <'\ttest_must_fail git submodule deinit &&\n'> <'\tgit submodule deinit . >actual &&\n'> <'\ttest -z "$(git config --get-regexp "submodule\\.example\\.")" &&\n'> <'\ttest -z "$(git config --get-regexp "submodule\\.example2\\.")" &&\n'> <'\ttest_i18ngrep "Cleared directory .init" actual &&\n'> <'\ttest_i18ngrep "Cleared directory .example2" actual &&\n'> <'\trmdir init example2\n'> ) } ) (C {(test_expect_success)} {(SQ <'submodule deinit --all deinits all initialized submodules'>)} { (SQ <'\n'> <'\tgit submodule update --init &&\n'> <'\tgit config submodule.example.foo bar &&\n'> <'\tgit config submodule.example2.frotz nitfol &&\n'> <'\ttest_must_fail git submodule deinit &&\n'> <'\tgit submodule deinit --all >actual &&\n'> <'\ttest -z "$(git config --get-regexp "submodule\\.example\\.")" &&\n'> <'\ttest -z "$(git config --get-regexp "submodule\\.example2\\.")" &&\n'> <'\ttest_i18ngrep "Cleared directory .init" actual &&\n'> <'\ttest_i18ngrep "Cleared directory .example2" actual &&\n'> <'\trmdir init example2\n'> ) } ) (C {(test_expect_success)} {(SQ <'submodule deinit deinits a submodule when its work tree is missing or empty'>)} { (SQ <'\n'> <'\tgit submodule update --init &&\n'> <'\trm -rf init example2/* example2/.git &&\n'> <'\tgit submodule deinit init example2 >actual &&\n'> <'\ttest -z "$(git config --get-regexp "submodule\\.example\\.")" &&\n'> <'\ttest -z "$(git config --get-regexp "submodule\\.example2\\.")" &&\n'> <'\ttest_i18ngrep ! "Cleared directory .init" actual &&\n'> <'\ttest_i18ngrep "Cleared directory .example2" actual &&\n'> <'\trmdir init\n'> ) } ) (C {(test_expect_success)} {(SQ <'submodule deinit fails when the submodule contains modifications unless forced'>)} { (SQ <'\n'> <'\tgit submodule update --init &&\n'> <'\techo X >>init/s &&\n'> <'\ttest_must_fail git submodule deinit init &&\n'> <'\ttest -n "$(git config --get-regexp "submodule\\.example\\.")" &&\n'> <'\ttest -f example2/.git &&\n'> <'\tgit submodule deinit -f init >actual &&\n'> <'\ttest -z "$(git config --get-regexp "submodule\\.example\\.")" &&\n'> <'\ttest_i18ngrep "Cleared directory .init" actual &&\n'> <'\trmdir init\n'> ) } ) (C {(test_expect_success)} {(SQ <'submodule deinit fails when the submodule contains untracked files unless forced'>)} { (SQ <'\n'> <'\tgit submodule update --init &&\n'> <'\techo X >>init/untracked &&\n'> <'\ttest_must_fail git submodule deinit init &&\n'> <'\ttest -n "$(git config --get-regexp "submodule\\.example\\.")" &&\n'> <'\ttest -f example2/.git &&\n'> <'\tgit submodule deinit -f init >actual &&\n'> <'\ttest -z "$(git config --get-regexp "submodule\\.example\\.")" &&\n'> <'\ttest_i18ngrep "Cleared directory .init" actual &&\n'> <'\trmdir init\n'> ) } ) (C {(test_expect_success)} {(SQ <'submodule deinit fails when the submodule HEAD does not match unless forced'>)} { (SQ <'\n'> <'\tgit submodule update --init &&\n'> <'\t(\n'> <'\t\tcd init &&\n'> <'\t\tgit checkout HEAD^\n'> <'\t) &&\n'> <'\ttest_must_fail git submodule deinit init &&\n'> <'\ttest -n "$(git config --get-regexp "submodule\\.example\\.")" &&\n'> <'\ttest -f example2/.git &&\n'> <'\tgit submodule deinit -f init >actual &&\n'> <'\ttest -z "$(git config --get-regexp "submodule\\.example\\.")" &&\n'> <'\ttest_i18ngrep "Cleared directory .init" actual &&\n'> <'\trmdir init\n'> ) } ) (C {(test_expect_success)} {(SQ <'submodule deinit is silent when used on an uninitialized submodule'>)} { (SQ <'\n'> <'\tgit submodule update --init &&\n'> <'\tgit submodule deinit init >actual &&\n'> <'\ttest_i18ngrep "Submodule .example. (.*) unregistered for path .init" actual &&\n'> <'\ttest_i18ngrep "Cleared directory .init" actual &&\n'> <'\tgit submodule deinit init >actual &&\n'> <'\ttest_i18ngrep ! "Submodule .example. (.*) unregistered for path .init" actual &&\n'> <'\ttest_i18ngrep "Cleared directory .init" actual &&\n'> <'\tgit submodule deinit . >actual &&\n'> <'\ttest_i18ngrep ! "Submodule .example. (.*) unregistered for path .init" actual &&\n'> <'\ttest_i18ngrep "Submodule .example2. (.*) unregistered for path .example2" actual &&\n'> <'\ttest_i18ngrep "Cleared directory .init" actual &&\n'> <'\tgit submodule deinit . >actual &&\n'> <'\ttest_i18ngrep ! "Submodule .example. (.*) unregistered for path .init" actual &&\n'> <'\ttest_i18ngrep ! "Submodule .example2. (.*) unregistered for path .example2" actual &&\n'> <'\ttest_i18ngrep "Cleared directory .init" actual &&\n'> <'\tgit submodule deinit --all >actual &&\n'> <'\ttest_i18ngrep ! "Submodule .example. (.*) unregistered for path .init" actual &&\n'> <'\ttest_i18ngrep ! "Submodule .example2. (.*) unregistered for path .example2" actual &&\n'> <'\ttest_i18ngrep "Cleared directory .init" actual &&\n'> <'\trmdir init example2\n'> ) } ) (C {(test_expect_success)} {(SQ <'submodule deinit fails when submodule has a .git directory even when forced'>)} { (SQ <'\n'> <'\tgit submodule update --init &&\n'> <'\t(\n'> <'\t\tcd init &&\n'> <'\t\trm .git &&\n'> <'\t\tcp -R ../.git/modules/example .git &&\n'> <'\t\tGIT_WORK_TREE=. git config --unset core.worktree\n'> <'\t) &&\n'> <'\ttest_must_fail git submodule deinit init &&\n'> <'\ttest_must_fail git submodule deinit -f init &&\n'> <'\ttest -d init/.git &&\n'> <'\ttest -n "$(git config --get-regexp "submodule\\.example\\.")"\n'> ) } ) (C {(test_expect_success)} {(SQ <'submodule with UTF-8 name'>)} { (SQ <'\n'> <'\tsvname=$(printf "\\303\\245 \\303\\244\\303\\266") &&\n'> <'\tmkdir "$svname" &&\n'> <'\t(\n'> <'\t\tcd "$svname" &&\n'> <'\t\tgit init &&\n'> <'\t\t>sub &&\n'> <'\t\tgit add sub &&\n'> <'\t\tgit commit -m "init sub"\n'> <'\t) &&\n'> <'\tgit submodule add ./"$svname" &&\n'> <'\tgit submodule >&2 &&\n'> <'\ttest -n "$(git submodule | grep "$svname")"\n'> ) } ) (C {(test_expect_success)} {(SQ <'submodule add clone shallow submodule'>)} { (SQ <'\n'> <'\tmkdir super &&\n'> <'\tpwd=$(pwd) &&\n'> <'\t(\n'> <'\t\tcd super &&\n'> <'\t\tgit init &&\n'> <'\t\tgit submodule add --depth=1 file://"$pwd"/example2 submodule &&\n'> <'\t\t(\n'> <'\t\t\tcd submodule &&\n'> <'\t\t\ttest 1 = $(git log --oneline | wc -l)\n'> <'\t\t)\n'> <'\t)\n'> ) } ) (C {(test_expect_success)} {(SQ <'submodule helper list is not confused by common prefixes'>)} { (SQ <'\n'> <'\tmkdir -p dir1/b &&\n'> <'\t(\n'> <'\t\tcd dir1/b &&\n'> <'\t\tgit init &&\n'> <'\t\techo hi >testfile2 &&\n'> <'\t\tgit add . &&\n'> <'\t\tgit commit -m "test1"\n'> <'\t) &&\n'> <'\tmkdir -p dir2/b &&\n'> <'\t(\n'> <'\t\tcd dir2/b &&\n'> <'\t\tgit init &&\n'> <'\t\techo hello >testfile1 &&\n'> <'\t\tgit add . &&\n'> <'\t\tgit commit -m "test2"\n'> <'\t) &&\n'> <'\tgit submodule add /dir1/b dir1/b &&\n'> <'\tgit submodule add /dir2/b dir2/b &&\n'> <'\tgit commit -m "first submodule commit" &&\n'> <'\tgit submodule--helper list dir1/b |cut -c51- >actual &&\n'> <'\techo "dir1/b" >expect &&\n'> <'\ttest_cmp expect actual\n'> ) } ) (C {(test_done)}) ] )