(command.CommandList children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'test_description='> name:test_description) op: assign_op.Equal rhs: { (SQ <'git submodule sync\n'> <'\n'> <'These tests exercise the "git submodule sync" subcommand.\n'> ) } spids: [13] ) ] redirects: [] ) (C {<.>} {<'./test-lib.sh'>}) (C {<test_expect_success>} {<setup>} { (SQ <'\n'> <'\techo file >file &&\n'> <'\tgit add file &&\n'> <'\ttest_tick &&\n'> <'\tgit commit -m upstream &&\n'> <'\tgit clone . super &&\n'> <'\tgit clone super submodule &&\n'> <'\t(\n'> <'\t\tcd submodule &&\n'> <'\t\tgit submodule add ../submodule sub-submodule &&\n'> <'\t\ttest_tick &&\n'> <'\t\tgit commit -m "sub-submodule"\n'> <'\t) &&\n'> <'\t(\n'> <'\t\tcd super &&\n'> <'\t\tgit submodule add ../submodule submodule &&\n'> <'\t\ttest_tick &&\n'> <'\t\tgit commit -m "submodule"\n'> <'\t) &&\n'> <'\tgit clone super super-clone &&\n'> <'\t(\n'> <'\t\tcd super-clone &&\n'> <'\t\tgit submodule update --init --recursive\n'> <'\t) &&\n'> <'\tgit clone super empty-clone &&\n'> <'\t(\n'> <'\t\tcd empty-clone &&\n'> <'\t\tgit submodule init\n'> <'\t) &&\n'> <'\tgit clone super top-only-clone &&\n'> <'\tgit clone super relative-clone &&\n'> <'\t(\n'> <'\t\tcd relative-clone &&\n'> <'\t\tgit submodule update --init --recursive\n'> <'\t) &&\n'> <'\tgit clone super recursive-clone &&\n'> <'\t(\n'> <'\t\tcd recursive-clone &&\n'> <'\t\tgit submodule update --init --recursive\n'> <'\t)\n'> ) } ) (C {<test_expect_success>} {(SQ <'change submodule'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd submodule &&\n'> <'\t\techo second line >>file &&\n'> <'\t\ttest_tick &&\n'> <'\t\tgit commit -a -m "change submodule"\n'> <'\t)\n'> ) } ) (command.ShFunction name: reset_submodule_urls body: (BraceGroup left: <Id.Lit_LBrace '{'> children: [ (command.AndOr ops: [Id.Op_DAmp] children: [ (command.Subshell child: (command.AndOr ops: [Id.Op_DAmp Id.Op_DAmp] children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'root='> name:root) op: assign_op.Equal rhs: { (command_sub left_token: <Id.Left_DollarParen '$('> child: (C {<pwd>}) right: <Id.Eof_RParen _> ) } spids: [102] ) ] redirects: [] ) (C {<cd>} {<'super-clone/submodule'>}) (C {<git>} {<config>} {<remote.origin.url>} {(DQ ($ Id.VSub_DollarName root) <'/submodule'>)} ) ] ) redirects: [] ) (command.Subshell child: (command.AndOr ops: [Id.Op_DAmp Id.Op_DAmp] children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'root='> name:root) op: assign_op.Equal rhs: { (command_sub left_token: <Id.Left_DollarParen '$('> child: (C {<pwd>}) right: <Id.Eof_RParen _> ) } spids: [137] ) ] redirects: [] ) (C {<cd>} {<'super-clone/submodule/sub-submodule'>}) (C {<git>} {<config>} {<remote.origin.url>} {(DQ ($ Id.VSub_DollarName root) <'/submodule'>)} ) ] ) redirects: [] ) ] ) ] redirects: [] right: <Id.Lit_RBrace '}'> ) ) (C {<test_expect_success>} {(SQ <'change submodule url'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd super &&\n'> <'\t\tcd submodule &&\n'> <'\t\tgit checkout master &&\n'> <'\t\tgit pull\n'> <'\t) &&\n'> <'\tmv submodule moved-submodule &&\n'> <'\t(\n'> <'\t\tcd moved-submodule &&\n'> <'\t\tgit config -f .gitmodules submodule.sub-submodule.url ../moved-submodule &&\n'> <'\t\ttest_tick &&\n'> <'\t\tgit commit -a -m moved-sub-submodule\n'> <'\t) &&\n'> <'\t(\n'> <'\t\tcd super &&\n'> <'\t\tgit config -f .gitmodules submodule.submodule.url ../moved-submodule &&\n'> <'\t\ttest_tick &&\n'> <'\t\tgit commit -a -m moved-submodule\n'> <'\t)\n'> ) } ) (C {<test_expect_success>} {(SQ <'"git submodule sync" should update submodule URLs'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd super-clone &&\n'> <'\t\tgit pull --no-recurse-submodules &&\n'> <'\t\tgit submodule sync\n'> <'\t) &&\n'> <'\ttest -d "$(\n'> <'\t\tcd super-clone/submodule &&\n'> <'\t\tgit config remote.origin.url\n'> <'\t)" &&\n'> <'\ttest ! -d "$(\n'> <'\t\tcd super-clone/submodule/sub-submodule &&\n'> <'\t\tgit config remote.origin.url\n'> <'\t)" &&\n'> <'\t(\n'> <'\t\tcd super-clone/submodule &&\n'> <'\t\tgit checkout master &&\n'> <'\t\tgit pull\n'> <'\t) &&\n'> <'\t(\n'> <'\t\tcd super-clone &&\n'> <'\t\ttest -d "$(git config submodule.submodule.url)"\n'> <'\t)\n'> ) } ) (C {<test_expect_success>} {(SQ <'"git submodule sync --recursive" should update all submodule URLs'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd super-clone &&\n'> <'\t\t(\n'> <'\t\t\tcd submodule &&\n'> <'\t\t\tgit pull --no-recurse-submodules\n'> <'\t\t) &&\n'> <'\t\tgit submodule sync --recursive\n'> <'\t) &&\n'> <'\ttest -d "$(\n'> <'\t\tcd super-clone/submodule &&\n'> <'\t\tgit config remote.origin.url\n'> <'\t)" &&\n'> <'\ttest -d "$(\n'> <'\t\tcd super-clone/submodule/sub-submodule &&\n'> <'\t\tgit config remote.origin.url\n'> <'\t)" &&\n'> <'\t(\n'> <'\t\tcd super-clone/submodule/sub-submodule &&\n'> <'\t\tgit checkout master &&\n'> <'\t\tgit pull\n'> <'\t)\n'> ) } ) (C {<test_expect_success>} {(SQ <'reset submodule URLs'>)} {(SQ <'\n'> <'\treset_submodule_urls super-clone\n'>)} ) (C {<test_expect_success>} {(SQ <'"git submodule sync" should update submodule URLs - subdirectory'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd super-clone &&\n'> <'\t\tgit pull --no-recurse-submodules &&\n'> <'\t\tmkdir -p sub &&\n'> <'\t\tcd sub &&\n'> <'\t\tgit submodule sync >../../output\n'> <'\t) &&\n'> <'\ttest_i18ngrep "\\\\.\\\\./submodule" output &&\n'> <'\ttest -d "$(\n'> <'\t\tcd super-clone/submodule &&\n'> <'\t\tgit config remote.origin.url\n'> <'\t)" &&\n'> <'\ttest ! -d "$(\n'> <'\t\tcd super-clone/submodule/sub-submodule &&\n'> <'\t\tgit config remote.origin.url\n'> <'\t)" &&\n'> <'\t(\n'> <'\t\tcd super-clone/submodule &&\n'> <'\t\tgit checkout master &&\n'> <'\t\tgit pull\n'> <'\t) &&\n'> <'\t(\n'> <'\t\tcd super-clone &&\n'> <'\t\ttest -d "$(git config submodule.submodule.url)"\n'> <'\t)\n'> ) } ) (C {<test_expect_success>} {(SQ <'"git submodule sync --recursive" should update all submodule URLs - subdirectory'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd super-clone &&\n'> <'\t\t(\n'> <'\t\t\tcd submodule &&\n'> <'\t\t\tgit pull --no-recurse-submodules\n'> <'\t\t) &&\n'> <'\t\tmkdir -p sub &&\n'> <'\t\tcd sub &&\n'> <'\t\tgit submodule sync --recursive >../../output\n'> <'\t) &&\n'> <'\ttest_i18ngrep "\\\\.\\\\./submodule/sub-submodule" output &&\n'> <'\ttest -d "$(\n'> <'\t\tcd super-clone/submodule &&\n'> <'\t\tgit config remote.origin.url\n'> <'\t)" &&\n'> <'\ttest -d "$(\n'> <'\t\tcd super-clone/submodule/sub-submodule &&\n'> <'\t\tgit config remote.origin.url\n'> <'\t)" &&\n'> <'\t(\n'> <'\t\tcd super-clone/submodule/sub-submodule &&\n'> <'\t\tgit checkout master &&\n'> <'\t\tgit pull\n'> <'\t)\n'> ) } ) (C {<test_expect_success>} {(SQ <'"git submodule sync" should update known submodule URLs'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd empty-clone &&\n'> <'\t\tgit pull &&\n'> <'\t\tgit submodule sync &&\n'> <'\t\ttest -d "$(git config submodule.submodule.url)"\n'> <'\t)\n'> ) } ) (C {<test_expect_success>} {(SQ <'"git submodule sync" should not vivify uninteresting submodule'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd top-only-clone &&\n'> <'\t\tgit pull &&\n'> <'\t\tgit submodule sync &&\n'> <'\t\ttest -z "$(git config submodule.submodule.url)" &&\n'> <'\t\tgit submodule sync submodule &&\n'> <'\t\ttest -z "$(git config submodule.submodule.url)"\n'> <'\t)\n'> ) } ) (C {<test_expect_success>} {(SQ <'"git submodule sync" handles origin URL of the form foo'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd relative-clone &&\n'> <'\t\tgit remote set-url origin foo &&\n'> <'\t\tgit submodule sync &&\n'> <'\t\t(\n'> <'\t\t\tcd submodule &&\n'> <'\t\t\t#actual fails with: "cannot strip off url foo\n'> <'\t\t\ttest "$(git config remote.origin.url)" = "../submodule"\n'> <'\t\t)\n'> <'\t)\n'> ) } ) (C {<test_expect_success>} {(SQ <'"git submodule sync" handles origin URL of the form foo/bar'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd relative-clone &&\n'> <'\t\tgit remote set-url origin foo/bar &&\n'> <'\t\tgit submodule sync &&\n'> <'\t\t(\n'> <'\t\t\tcd submodule &&\n'> <'\t\t\t#actual foo/submodule\n'> <'\t\t\ttest "$(git config remote.origin.url)" = "../foo/submodule"\n'> <'\t\t) &&\n'> <'\t\t(\n'> <'\t\t\tcd submodule/sub-submodule &&\n'> <'\t\t\ttest "$(git config remote.origin.url)" != "../../foo/submodule"\n'> <'\t\t)\n'> <'\t)\n'> ) } ) (C {<test_expect_success>} {(SQ <'"git submodule sync --recursive" propagates changes in origin'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd recursive-clone &&\n'> <'\t\tgit remote set-url origin foo/bar &&\n'> <'\t\tgit submodule sync --recursive &&\n'> <'\t\t(\n'> <'\t\t\tcd submodule &&\n'> <'\t\t\t#actual foo/submodule\n'> <'\t\t\ttest "$(git config remote.origin.url)" = "../foo/submodule"\n'> <'\t\t) &&\n'> <'\t\t(\n'> <'\t\t\tcd submodule/sub-submodule &&\n'> <'\t\t\ttest "$(git config remote.origin.url)" = "../../foo/submodule"\n'> <'\t\t)\n'> <'\t)\n'> ) } ) (C {<test_expect_success>} {(SQ <'"git submodule sync" handles origin URL of the form ./foo'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd relative-clone &&\n'> <'\t\tgit remote set-url origin ./foo &&\n'> <'\t\tgit submodule sync &&\n'> <'\t\t(\n'> <'\t\t\tcd submodule &&\n'> <'\t\t\t#actual ./submodule\n'> <'\t\t\ttest "$(git config remote.origin.url)" = "../submodule"\n'> <'\t\t)\n'> <'\t)\n'> ) } ) (C {<test_expect_success>} {(SQ <'"git submodule sync" handles origin URL of the form ./foo/bar'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd relative-clone &&\n'> <'\t\tgit remote set-url origin ./foo/bar &&\n'> <'\t\tgit submodule sync &&\n'> <'\t\t(\n'> <'\t\t\tcd submodule &&\n'> <'\t\t\t#actual ./foo/submodule\n'> <'\t\t\ttest "$(git config remote.origin.url)" = "../foo/submodule"\n'> <'\t\t)\n'> <'\t)\n'> ) } ) (C {<test_expect_success>} {(SQ <'"git submodule sync" handles origin URL of the form ../foo'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd relative-clone &&\n'> <'\t\tgit remote set-url origin ../foo &&\n'> <'\t\tgit submodule sync &&\n'> <'\t\t(\n'> <'\t\t\tcd submodule &&\n'> <'\t\t\t#actual ../submodule\n'> <'\t\t\ttest "$(git config remote.origin.url)" = "../../submodule"\n'> <'\t\t)\n'> <'\t)\n'> ) } ) (C {<test_expect_success>} {(SQ <'"git submodule sync" handles origin URL of the form ../foo/bar'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd relative-clone &&\n'> <'\t\tgit remote set-url origin ../foo/bar &&\n'> <'\t\tgit submodule sync &&\n'> <'\t\t(\n'> <'\t\t\tcd submodule &&\n'> <'\t\t\t#actual ../foo/submodule\n'> <'\t\t\ttest "$(git config remote.origin.url)" = "../../foo/submodule"\n'> <'\t\t)\n'> <'\t)\n'> ) } ) (C {<test_expect_success>} { (SQ < '"git submodule sync" handles origin URL of the form ../foo/bar with deeply nested submodule' > ) } { (SQ <'\n'> <'\t(\n'> <'\t\tcd relative-clone &&\n'> <'\t\tgit remote set-url origin ../foo/bar &&\n'> <'\t\tmkdir -p a/b/c &&\n'> <'\t\t(\n'> <'\t\t\tcd a/b/c &&\n'> <'\t\t\tgit init &&\n'> <'\t\t\t>.gitignore &&\n'> <'\t\t\tgit add .gitignore &&\n'> <'\t\t\ttest_tick &&\n'> <'\t\t\tgit commit -m "initial commit"\n'> <'\t\t) &&\n'> <'\t\tgit submodule add ../bar/a/b/c ./a/b/c &&\n'> <'\t\tgit submodule sync &&\n'> <'\t\t(\n'> <'\t\t\tcd a/b/c &&\n'> <'\t\t\t#actual ../foo/bar/a/b/c\n'> <'\t\t\ttest "$(git config remote.origin.url)" = "../../../../foo/bar/a/b/c"\n'> <'\t\t)\n'> <'\t)\n'> ) } ) (C {<test_done>}) ] )