(CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: { (SQ <"Test updating submodules\n"> <"\n"> <"This test verifies that \"git submodule update\" detaches the HEAD of the\n"> <"submodule and \"git submodule update --rebase/--merge\" does not detach the HEAD.\n"> ) } spids: [13] ) ] spids: [13] ) (C {(.)} {(./test-lib.sh)}) (FuncDef name: compare_head body: (BraceGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:sha_master) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (C {(git)} {(rev-list)} {(--max-count) (Lit_Other "=") (1)} {(master)}) ] ) left_token: <Left_CommandSub "$("> spids: [36 46] ) } spids: [35] ) ] spids: [35] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:sha_head) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (C {(git)} {(rev-list)} {(--max-count) (Lit_Other "=") (1)} {(HEAD)}) ] ) left_token: <Left_CommandSub "$("> spids: [50 60] ) } spids: [49] ) ] spids: [49] ) (C {(test)} {(DQ ($ VSub_Name "$sha_master"))} {(Lit_Other "=")} {(DQ ($ VSub_Name "$sha_head"))} ) ] spids: [32] ) spids: [28 31] ) (C {(test_expect_success)} {(SQ <"setup a submodule tree">)} { (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"> <"\tgit clone super rebasing &&\n"> <"\tgit clone super merging &&\n"> <"\tgit clone super none &&\n"> <"\t(cd super &&\n"> <"\t git submodule add ../submodule submodule &&\n"> <"\t test_tick &&\n"> <"\t git commit -m \"submodule\" &&\n"> <"\t git submodule init submodule\n"> <"\t) &&\n"> <"\t(cd submodule &&\n"> <"\techo \"line2\" > file &&\n"> <"\tgit add file &&\n"> <"\tgit commit -m \"Commit 2\"\n"> <"\t) &&\n"> <"\t(cd super &&\n"> <"\t (cd submodule &&\n"> <"\t git pull --rebase origin\n"> <"\t ) &&\n"> <"\t git add submodule &&\n"> <"\t git commit -m \"submodule update\"\n"> <"\t) &&\n"> <"\t(cd super &&\n"> <"\t git submodule add ../rebasing rebasing &&\n"> <"\t test_tick &&\n"> <"\t git commit -m \"rebasing\"\n"> <"\t) &&\n"> <"\t(cd super &&\n"> <"\t git submodule add ../merging merging &&\n"> <"\t test_tick &&\n"> <"\t git commit -m \"rebasing\"\n"> <"\t) &&\n"> <"\t(cd super &&\n"> <"\t git submodule add ../none none &&\n"> <"\t test_tick &&\n"> <"\t git commit -m \"none\"\n"> <"\t) &&\n"> <"\tgit clone . recursivesuper &&\n"> <"\t( cd recursivesuper\n"> <"\t git submodule add ../super super\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"submodule update detaching the HEAD ">)} { (SQ <"\n"> <"\t(cd super/submodule &&\n"> <"\t git reset --hard HEAD~1\n"> <"\t) &&\n"> <"\t(cd super &&\n"> <"\t (cd submodule &&\n"> <"\t compare_head\n"> <"\t ) &&\n"> <"\t git submodule update submodule &&\n"> <"\t cd submodule &&\n"> <"\t ! compare_head\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"submodule update from subdirectory">)} { (SQ <"\n"> <"\t(cd super/submodule &&\n"> <"\t git reset --hard HEAD~1\n"> <"\t) &&\n"> <"\tmkdir super/sub &&\n"> <"\t(cd super/sub &&\n"> <"\t (cd ../submodule &&\n"> <"\t compare_head\n"> <"\t ) &&\n"> <"\t git submodule update ../submodule &&\n"> <"\t cd ../submodule &&\n"> <"\t ! compare_head\n"> <"\t)\n"> ) } ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:supersha1) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [(C {(git)} {(-C)} {(super)} {(rev-parse)} {(HEAD)})] ) left_token: <Left_CommandSub "$("> spids: [183 193] ) } spids: [182] ) ] spids: [182] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:mergingsha1) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [(C {(git)} {(-C)} {(super/merging)} {(rev-parse)} {(HEAD)})] ) left_token: <Left_CommandSub "$("> spids: [196 206] ) } spids: [195] ) ] spids: [195] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:nonesha1) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [(C {(git)} {(-C)} {(super/none)} {(rev-parse)} {(HEAD)})] ) left_token: <Left_CommandSub "$("> spids: [209 219] ) } spids: [208] ) ] spids: [208] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:rebasingsha1) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [(C {(git)} {(-C)} {(super/rebasing)} {(rev-parse)} {(HEAD)})] ) left_token: <Left_CommandSub "$("> spids: [222 232] ) } spids: [221] ) ] spids: [221] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:submodulesha1) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [(C {(git)} {(-C)} {(super/submodule)} {(rev-parse)} {(HEAD)})] ) left_token: <Left_CommandSub "$("> spids: [235 245] ) } spids: [234] ) ] spids: [234] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:pwd) op: Equal rhs: { (CommandSubPart command_list: (CommandList children:[(C {(pwd)})]) left_token: <Left_CommandSub "$("> spids: [248 250] ) } spids: [247] ) ] spids: [247] ) (SimpleCommand words: [{(cat)}] redirects: [ (HereDoc op_id: Redir_DLess fd: -1 body: { (DQ ("Submodule path '../super': checked out '") ($ VSub_Name "$supersha1") ("'\n") ("Submodule path '../super/merging': checked out '") ($ VSub_Name "$mergingsha1") ("'\n") ("Submodule path '../super/none': checked out '") ($ VSub_Name "$nonesha1") ("'\n") ("Submodule path '../super/rebasing': checked out '") ($ VSub_Name "$rebasingsha1") ("'\n") ("Submodule path '../super/submodule': checked out '") ($ VSub_Name "$submodulesha1") ("'\n") ) } do_expansion: True here_end: EOF was_filled: True spids: [255] ) (Redir op_id:Redir_Great fd:-1 arg_word:{(expect)} spids:[258]) ] ) (SimpleCommand words: [{(cat)}] redirects: [ (HereDoc op_id: Redir_DLess fd: -1 body: { (DQ ("Submodule 'merging' (") ($ VSub_Name "$pwd") ("/merging) registered for path '../super/merging'\n") ("Submodule 'none' (") ($ VSub_Name "$pwd") ("/none) registered for path '../super/none'\n") ("Submodule 'rebasing' (") ($ VSub_Name "$pwd") ("/rebasing) registered for path '../super/rebasing'\n") ("Submodule 'submodule' (") ($ VSub_Name "$pwd") ("/submodule) registered for path '../super/submodule'\n") ("Cloning into '") ($ VSub_Name "$pwd") ("/recursivesuper/super/merging'...\n") ("done.\n") ("Cloning into '") ($ VSub_Name "$pwd") ("/recursivesuper/super/none'...\n") ("done.\n") ("Cloning into '") ($ VSub_Name "$pwd") ("/recursivesuper/super/rebasing'...\n") ("done.\n") ("Cloning into '") ($ VSub_Name "$pwd") ("/recursivesuper/super/submodule'...\n") ("done.\n") ) } do_expansion: True here_end: EOF was_filled: True spids: [279] ) (Redir op_id:Redir_Great fd:-1 arg_word:{(expect2)} spids:[282]) ] ) (C {(test_expect_success)} {(SQ <"submodule update --init --recursive from subdirectory">)} { (SQ <"\n"> <"\tgit -C recursivesuper/super reset --hard HEAD^ &&\n"> <"\t(cd recursivesuper &&\n"> <"\t mkdir tmp &&\n"> <"\t cd tmp &&\n"> <"\t git submodule update --init --recursive ../super >../../actual 2>../../actual2\n"> <"\t) &&\n"> <"\ttest_i18ncmp expect actual &&\n"> <"\ttest_i18ncmp expect2 actual2\n"> ) } ) (Sentence child: (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:apos) op:Equal rhs:{(DQ ("'"))} spids:[333])] spids: [333] ) terminator: <Op_Semi ";"> ) (C {(test_expect_success)} {(SQ <"submodule update does not fetch already present commits">)} { (SQ <"\n"> <"\t(cd submodule &&\n"> <"\t echo line3 >> file &&\n"> <"\t git add file &&\n"> <"\t test_tick &&\n"> <"\t git commit -m \"upstream line3\"\n"> <"\t) &&\n"> <"\t(cd super/submodule &&\n"> <"\t head=$(git rev-parse --verify HEAD) &&\n"> < "\t echo \"Submodule path ${apos}submodule$apos: checked out $apos$head$apos\" > ../../expected &&\n" > <"\t git reset --hard HEAD~1\n"> <"\t) &&\n"> <"\t(cd super &&\n"> <"\t git submodule update > ../actual 2> ../actual.err\n"> <"\t) &&\n"> <"\ttest_i18ncmp expected actual &&\n"> <"\t! test -s actual.err\n"> ) } ) (C {(test_expect_success)} {(SQ <"submodule update should fail due to local changes">)} { (SQ <"\n"> <"\t(cd super/submodule &&\n"> <"\t git reset --hard HEAD~1 &&\n"> <"\t echo \"local change\" > file\n"> <"\t) &&\n"> <"\t(cd super &&\n"> <"\t (cd submodule &&\n"> <"\t compare_head\n"> <"\t ) &&\n"> <"\t test_must_fail git submodule update submodule\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"submodule update should throw away changes with --force ">)} { (SQ <"\n"> <"\t(cd super &&\n"> <"\t (cd submodule &&\n"> <"\t compare_head\n"> <"\t ) &&\n"> <"\t git submodule update --force submodule &&\n"> <"\t cd submodule &&\n"> <"\t ! compare_head\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"submodule update --force forcibly checks out submodules">)} { (SQ <"\n"> <"\t(cd super &&\n"> <"\t (cd submodule &&\n"> <"\t rm -f file\n"> <"\t ) &&\n"> <"\t git submodule update --force submodule &&\n"> <"\t (cd submodule &&\n"> <"\t test \"$(git status -s file)\" = \"\"\n"> <"\t )\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"submodule update --remote should fetch upstream changes">)} { (SQ <"\n"> <"\t(cd submodule &&\n"> <"\t echo line4 >> file &&\n"> <"\t git add file &&\n"> <"\t test_tick &&\n"> <"\t git commit -m \"upstream line4\"\n"> <"\t) &&\n"> <"\t(cd super &&\n"> <"\t git submodule update --remote --force submodule &&\n"> <"\t cd submodule &&\n"> < "\t test \"$(git log -1 --oneline)\" = \"$(GIT_DIR=../../submodule/.git git log -1 --oneline)\"\n" > <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"submodule update --remote should fetch upstream changes with .">)} { (SQ <"\n"> <"\t(\n"> <"\t\tcd super &&\n"> <"\t\tgit config -f .gitmodules submodule.\"submodule\".branch \".\" &&\n"> <"\t\tgit add .gitmodules &&\n"> <"\t\tgit commit -m \"submodules: update from the respective superproject branch\"\n"> <"\t) &&\n"> <"\t(\n"> <"\t\tcd submodule &&\n"> <"\t\techo line4a >> file &&\n"> <"\t\tgit add file &&\n"> <"\t\ttest_tick &&\n"> <"\t\tgit commit -m \"upstream line4a\" &&\n"> <"\t\tgit checkout -b test-branch &&\n"> <"\t\ttest_commit on-test-branch\n"> <"\t) &&\n"> <"\t(\n"> <"\t\tcd super &&\n"> <"\t\tgit submodule update --remote --force submodule &&\n"> <"\t\tgit -C submodule log -1 --oneline >actual\n"> <"\t\tgit -C ../submodule log -1 --oneline master >expect\n"> <"\t\ttest_cmp expect actual &&\n"> <"\t\tgit checkout -b test-branch &&\n"> <"\t\tgit submodule update --remote --force submodule &&\n"> <"\t\tgit -C submodule log -1 --oneline >actual\n"> <"\t\tgit -C ../submodule log -1 --oneline test-branch >expect\n"> <"\t\ttest_cmp expect actual &&\n"> <"\t\tgit checkout master &&\n"> <"\t\tgit branch -d test-branch &&\n"> <"\t\tgit reset --hard HEAD^\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"local config should override .gitmodules branch">)} { (SQ <"\n"> <"\t(cd submodule &&\n"> <"\t git checkout test-branch &&\n"> <"\t echo line5 >> file &&\n"> <"\t git add file &&\n"> <"\t test_tick &&\n"> <"\t git commit -m \"upstream line5\" &&\n"> <"\t git checkout master\n"> <"\t) &&\n"> <"\t(cd super &&\n"> <"\t git config submodule.submodule.branch test-branch &&\n"> <"\t git submodule update --remote --force submodule &&\n"> <"\t cd submodule &&\n"> < "\t test \"$(git log -1 --oneline)\" = \"$(GIT_DIR=../../submodule/.git git log -1 --oneline test-branch)\"\n" > <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"submodule update --rebase staying on master">)} { (SQ <"\n"> <"\t(cd super/submodule &&\n"> <"\t git checkout master\n"> <"\t) &&\n"> <"\t(cd super &&\n"> <"\t (cd submodule &&\n"> <"\t compare_head\n"> <"\t ) &&\n"> <"\t git submodule update --rebase submodule &&\n"> <"\t cd submodule &&\n"> <"\t compare_head\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"submodule update --merge staying on master">)} { (SQ <"\n"> <"\t(cd super/submodule &&\n"> <"\t git reset --hard HEAD~1\n"> <"\t) &&\n"> <"\t(cd super &&\n"> <"\t (cd submodule &&\n"> <"\t compare_head\n"> <"\t ) &&\n"> <"\t git submodule update --merge submodule &&\n"> <"\t cd submodule &&\n"> <"\t compare_head\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"submodule update - rebase in .git/config">)} { (SQ <"\n"> <"\t(cd super &&\n"> <"\t git config submodule.submodule.update rebase\n"> <"\t) &&\n"> <"\t(cd super/submodule &&\n"> <"\t git reset --hard HEAD~1\n"> <"\t) &&\n"> <"\t(cd super &&\n"> <"\t (cd submodule &&\n"> <"\t compare_head\n"> <"\t ) &&\n"> <"\t git submodule update submodule &&\n"> <"\t cd submodule &&\n"> <"\t compare_head\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"submodule update - checkout in .git/config but --rebase given">)} { (SQ <"\n"> <"\t(cd super &&\n"> <"\t git config submodule.submodule.update checkout\n"> <"\t) &&\n"> <"\t(cd super/submodule &&\n"> <"\t git reset --hard HEAD~1\n"> <"\t) &&\n"> <"\t(cd super &&\n"> <"\t (cd submodule &&\n"> <"\t compare_head\n"> <"\t ) &&\n"> <"\t git submodule update --rebase submodule &&\n"> <"\t cd submodule &&\n"> <"\t compare_head\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"submodule update - merge in .git/config">)} { (SQ <"\n"> <"\t(cd super &&\n"> <"\t git config submodule.submodule.update merge\n"> <"\t) &&\n"> <"\t(cd super/submodule &&\n"> <"\t git reset --hard HEAD~1\n"> <"\t) &&\n"> <"\t(cd super &&\n"> <"\t (cd submodule &&\n"> <"\t compare_head\n"> <"\t ) &&\n"> <"\t git submodule update submodule &&\n"> <"\t cd submodule &&\n"> <"\t compare_head\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"submodule update - checkout in .git/config but --merge given">)} { (SQ <"\n"> <"\t(cd super &&\n"> <"\t git config submodule.submodule.update checkout\n"> <"\t) &&\n"> <"\t(cd super/submodule &&\n"> <"\t git reset --hard HEAD~1\n"> <"\t) &&\n"> <"\t(cd super &&\n"> <"\t (cd submodule &&\n"> <"\t compare_head\n"> <"\t ) &&\n"> <"\t git submodule update --merge submodule &&\n"> <"\t cd submodule &&\n"> <"\t compare_head\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"submodule update - checkout in .git/config">)} { (SQ <"\n"> <"\t(cd super &&\n"> <"\t git config submodule.submodule.update checkout\n"> <"\t) &&\n"> <"\t(cd super/submodule &&\n"> <"\t git reset --hard HEAD^\n"> <"\t) &&\n"> <"\t(cd super &&\n"> <"\t (cd submodule &&\n"> <"\t compare_head\n"> <"\t ) &&\n"> <"\t git submodule update submodule &&\n"> <"\t cd submodule &&\n"> <"\t ! compare_head\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"submodule update - command in .git/config">)} { (SQ <"\n"> <"\t(cd super &&\n"> <"\t git config submodule.submodule.update \"!git checkout\"\n"> <"\t) &&\n"> <"\t(cd super/submodule &&\n"> <"\t git reset --hard HEAD^\n"> <"\t) &&\n"> <"\t(cd super &&\n"> <"\t (cd submodule &&\n"> <"\t compare_head\n"> <"\t ) &&\n"> <"\t git submodule update submodule &&\n"> <"\t cd submodule &&\n"> <"\t ! compare_head\n"> <"\t)\n"> ) } ) (SimpleCommand words: [{(cat)}] redirects: [ (HereDoc op_id: Redir_DLess fd: -1 body: { (DQ ("Execution of 'false ") ($ VSub_Name "$submodulesha1") ("' failed in submodule path 'submodule'\n") ) } do_expansion: True here_end: EOF was_filled: True spids: [709] ) (Redir op_id:Redir_Great fd:-1 arg_word:{(expect)} spids:[713]) ] ) (C {(test_expect_success)} {(SQ <"submodule update - command in .git/config catches failure">)} { (SQ <"\n"> <"\t(cd super &&\n"> <"\t git config submodule.submodule.update \"!false\"\n"> <"\t) &&\n"> <"\t(cd super/submodule &&\n"> <"\t git reset --hard $submodulesha1^\n"> <"\t) &&\n"> <"\t(cd super &&\n"> <"\t test_must_fail git submodule update submodule 2>../actual\n"> <"\t) &&\n"> <"\ttest_i18ncmp actual expect\n"> ) } ) (SimpleCommand words: [{(cat)}] redirects: [ (HereDoc op_id: Redir_DLess fd: -1 body: { (DQ ("Execution of 'false ") ($ VSub_Name "$submodulesha1") ("' failed in submodule path '../submodule'\n") ) } do_expansion: True here_end: EOF was_filled: True spids: [743] ) (Redir op_id:Redir_Great fd:-1 arg_word:{(expect)} spids:[747]) ] ) (C {(test_expect_success)} {(SQ <"submodule update - command in .git/config catches failure -- subdirectory">)} { (SQ <"\n"> <"\t(cd super &&\n"> <"\t git config submodule.submodule.update \"!false\"\n"> <"\t) &&\n"> <"\t(cd super/submodule &&\n"> <"\t git reset --hard $submodulesha1^\n"> <"\t) &&\n"> <"\t(cd super &&\n"> <"\t mkdir tmp && cd tmp &&\n"> <"\t test_must_fail git submodule update ../submodule 2>../../actual\n"> <"\t) &&\n"> <"\ttest_i18ncmp actual expect\n"> ) } ) (SimpleCommand words: [{(cat)}] redirects: [ (HereDoc op_id: Redir_DLess fd: -1 body: { (DQ ("Execution of 'false ") ($ VSub_Name "$submodulesha1") ("' failed in submodule path '../super/submodule'\n") ("Failed to recurse into submodule path '../super'\n") ) } do_expansion: True here_end: EOF was_filled: True spids: [778] ) (Redir op_id:Redir_Great fd:-1 arg_word:{(expect)} spids:[782]) ] ) (C {(test_expect_success)} {(SQ <"recursive submodule update - command in .git/config catches failure -- subdirectory">)} { (SQ <"\n"> <"\t(cd recursivesuper &&\n"> <"\t git submodule update --remote super &&\n"> <"\t git add super &&\n"> <"\t git commit -m \"update to latest to have more than one commit in submodules\"\n"> <"\t) &&\n"> <"\tgit -C recursivesuper/super config submodule.submodule.update \"!false\" &&\n"> <"\tgit -C recursivesuper/super/submodule reset --hard $submodulesha1^ &&\n"> <"\t(cd recursivesuper &&\n"> <"\t mkdir -p tmp && cd tmp &&\n"> <"\t test_must_fail git submodule update --recursive ../super 2>../../actual\n"> <"\t) &&\n"> <"\ttest_i18ncmp actual expect\n"> ) } ) (C {(test_expect_success)} {(SQ <"submodule init does not copy command into .git/config">)} { (SQ <"\n"> <"\t(cd super &&\n"> <"\t H=$(git ls-files -s submodule | cut -d\" \" -f2) &&\n"> <"\t mkdir submodule1 &&\n"> <"\t git update-index --add --cacheinfo 160000 $H submodule1 &&\n"> <"\t git config -f .gitmodules submodule.submodule1.path submodule1 &&\n"> <"\t git config -f .gitmodules submodule.submodule1.url ../submodule &&\n"> <"\t git config -f .gitmodules submodule.submodule1.update !false &&\n"> <"\t git submodule init submodule1 &&\n"> <"\t echo \"none\" >expect &&\n"> <"\t git config submodule.submodule1.update >actual &&\n"> <"\t test_cmp expect actual\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"submodule init picks up rebase">)} { (SQ <"\n"> <"\t(cd super &&\n"> <"\t git config -f .gitmodules submodule.rebasing.update rebase &&\n"> <"\t git submodule init rebasing &&\n"> <"\t test \"rebase\" = \"$(git config submodule.rebasing.update)\"\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"submodule init picks up merge">)} { (SQ <"\n"> <"\t(cd super &&\n"> <"\t git config -f .gitmodules submodule.merging.update merge &&\n"> <"\t git submodule init merging &&\n"> <"\t test \"merge\" = \"$(git config submodule.merging.update)\"\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"submodule update --merge - ignores --merge for new submodules">)} { (SQ <"\n"> <"\t(cd super &&\n"> <"\t rm -rf submodule &&\n"> <"\t git submodule update submodule &&\n"> <"\t git status -s submodule >expect &&\n"> <"\t rm -rf submodule &&\n"> <"\t git submodule update --merge submodule &&\n"> <"\t git status -s submodule >actual &&\n"> <"\t test_cmp expect actual\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"submodule update --rebase - ignores --rebase for new submodules">)} { (SQ <"\n"> <"\t(cd super &&\n"> <"\t rm -rf submodule &&\n"> <"\t git submodule update submodule &&\n"> <"\t git status -s submodule >expect &&\n"> <"\t rm -rf submodule &&\n"> <"\t git submodule update --rebase submodule &&\n"> <"\t git status -s submodule >actual &&\n"> <"\t test_cmp expect actual\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"submodule update ignores update=merge config for new submodules">)} { (SQ <"\n"> <"\t(cd super &&\n"> <"\t rm -rf submodule &&\n"> <"\t git submodule update submodule &&\n"> <"\t git status -s submodule >expect &&\n"> <"\t rm -rf submodule &&\n"> <"\t git config submodule.submodule.update merge &&\n"> <"\t git submodule update submodule &&\n"> <"\t git status -s submodule >actual &&\n"> <"\t git config --unset submodule.submodule.update &&\n"> <"\t test_cmp expect actual\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"submodule update ignores update=rebase config for new submodules">)} { (SQ <"\n"> <"\t(cd super &&\n"> <"\t rm -rf submodule &&\n"> <"\t git submodule update submodule &&\n"> <"\t git status -s submodule >expect &&\n"> <"\t rm -rf submodule &&\n"> <"\t git config submodule.submodule.update rebase &&\n"> <"\t git submodule update submodule &&\n"> <"\t git status -s submodule >actual &&\n"> <"\t git config --unset submodule.submodule.update &&\n"> <"\t test_cmp expect actual\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"submodule init picks up update=none">)} { (SQ <"\n"> <"\t(cd super &&\n"> <"\t git config -f .gitmodules submodule.none.update none &&\n"> <"\t git submodule init none &&\n"> <"\t test \"none\" = \"$(git config submodule.none.update)\"\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"submodule update - update=none in .git/config">)} { (SQ <"\n"> <"\t(cd super &&\n"> <"\t git config submodule.submodule.update none &&\n"> <"\t (cd submodule &&\n"> <"\t git checkout master &&\n"> <"\t compare_head\n"> <"\t ) &&\n"> <"\t git diff --raw | grep \"\tsubmodule\" &&\n"> <"\t git submodule update &&\n"> <"\t git diff --raw | grep \"\tsubmodule\" &&\n"> <"\t (cd submodule &&\n"> <"\t compare_head\n"> <"\t ) &&\n"> <"\t git config --unset submodule.submodule.update &&\n"> <"\t git submodule update submodule\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"submodule update - update=none in .git/config but --checkout given">)} { (SQ <"\n"> <"\t(cd super &&\n"> <"\t git config submodule.submodule.update none &&\n"> <"\t (cd submodule &&\n"> <"\t git checkout master &&\n"> <"\t compare_head\n"> <"\t ) &&\n"> <"\t git diff --raw | grep \"\tsubmodule\" &&\n"> <"\t git submodule update --checkout &&\n"> <"\t test_must_fail git diff --raw \\| grep \"\tsubmodule\" &&\n"> <"\t (cd submodule &&\n"> <"\t test_must_fail compare_head\n"> <"\t ) &&\n"> <"\t git config --unset submodule.submodule.update\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"submodule update --init skips submodule with update=none">)} { (SQ <"\n"> <"\t(cd super &&\n"> <"\t git add .gitmodules &&\n"> <"\t git commit -m \".gitmodules\"\n"> <"\t) &&\n"> <"\tgit clone super cloned &&\n"> <"\t(cd cloned &&\n"> <"\t git submodule update --init &&\n"> <"\t test -e submodule/.git &&\n"> <"\t test_must_fail test -e none/.git\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"submodule update continues after checkout error">)} { (SQ <"\n"> <"\t(cd super &&\n"> <"\t git reset --hard HEAD &&\n"> <"\t git submodule add ../submodule submodule2 &&\n"> <"\t git submodule init &&\n"> <"\t git commit -am \"new_submodule\" &&\n"> <"\t (cd submodule2 &&\n"> <"\t git rev-parse --verify HEAD >../expect\n"> <"\t ) &&\n"> <"\t (cd submodule &&\n"> <"\t test_commit \"update_submodule\" file\n"> <"\t ) &&\n"> <"\t (cd submodule2 &&\n"> <"\t test_commit \"update_submodule2\" file\n"> <"\t ) &&\n"> <"\t git add submodule &&\n"> <"\t git add submodule2 &&\n"> <"\t git commit -m \"two_new_submodule_commits\" &&\n"> <"\t (cd submodule &&\n"> <"\t echo \"\" > file\n"> <"\t ) &&\n"> <"\t git checkout HEAD^ &&\n"> <"\t test_must_fail git submodule update &&\n"> <"\t (cd submodule2 &&\n"> <"\t git rev-parse --verify HEAD >../actual\n"> <"\t ) &&\n"> <"\t test_cmp expect actual\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"submodule update continues after recursive checkout error">)} { (SQ <"\n"> <"\t(cd super &&\n"> <"\t git reset --hard HEAD &&\n"> <"\t git checkout master &&\n"> <"\t git submodule update &&\n"> <"\t (cd submodule &&\n"> <"\t git submodule add ../submodule subsubmodule &&\n"> <"\t git submodule init &&\n"> <"\t git commit -m \"new_subsubmodule\"\n"> <"\t ) &&\n"> <"\t git add submodule &&\n"> <"\t git commit -m \"update_submodule\" &&\n"> <"\t (cd submodule &&\n"> <"\t (cd subsubmodule &&\n"> <"\t test_commit \"update_subsubmodule\" file\n"> <"\t ) &&\n"> <"\t git add subsubmodule &&\n"> <"\t test_commit \"update_submodule_again\" file &&\n"> <"\t (cd subsubmodule &&\n"> <"\t test_commit \"update_subsubmodule_again\" file\n"> <"\t ) &&\n"> <"\t test_commit \"update_submodule_again_again\" file\n"> <"\t ) &&\n"> <"\t (cd submodule2 &&\n"> <"\t git rev-parse --verify HEAD >../expect &&\n"> <"\t test_commit \"update_submodule2_again\" file\n"> <"\t ) &&\n"> <"\t git add submodule &&\n"> <"\t git add submodule2 &&\n"> <"\t git commit -m \"new_commits\" &&\n"> <"\t git checkout HEAD^ &&\n"> <"\t (cd submodule &&\n"> <"\t git checkout HEAD^ &&\n"> <"\t (cd subsubmodule &&\n"> <"\t echo \"\" > file\n"> <"\t )\n"> <"\t ) &&\n"> <"\t test_must_fail git submodule update --recursive &&\n"> <"\t (cd submodule2 &&\n"> <"\t git rev-parse --verify HEAD >../actual\n"> <"\t ) &&\n"> <"\t test_cmp expect actual\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"submodule update exit immediately in case of merge conflict">)} { (SQ <"\n"> <"\t(cd super &&\n"> <"\t git checkout master &&\n"> <"\t git reset --hard HEAD &&\n"> <"\t (cd submodule &&\n"> <"\t (cd subsubmodule &&\n"> <"\t git reset --hard HEAD\n"> <"\t )\n"> <"\t ) &&\n"> <"\t git submodule update --recursive &&\n"> <"\t (cd submodule &&\n"> <"\t test_commit \"update_submodule_2\" file\n"> <"\t ) &&\n"> <"\t (cd submodule2 &&\n"> <"\t test_commit \"update_submodule2_2\" file\n"> <"\t ) &&\n"> <"\t git add submodule &&\n"> <"\t git add submodule2 &&\n"> <"\t git commit -m \"two_new_submodule_commits\" &&\n"> <"\t (cd submodule &&\n"> <"\t git checkout master &&\n"> <"\t test_commit \"conflict\" file &&\n"> <"\t echo \"conflict\" > file\n"> <"\t ) &&\n"> <"\t git checkout HEAD^ &&\n"> <"\t (cd submodule2 &&\n"> <"\t git rev-parse --verify HEAD >../expect\n"> <"\t ) &&\n"> <"\t git config submodule.submodule.update merge &&\n"> <"\t test_must_fail git submodule update &&\n"> <"\t (cd submodule2 &&\n"> <"\t git rev-parse --verify HEAD >../actual\n"> <"\t ) &&\n"> <"\t test_cmp expect actual\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"submodule update exit immediately after recursive rebase error">)} { (SQ <"\n"> <"\t(cd super &&\n"> <"\t git checkout master &&\n"> <"\t git reset --hard HEAD &&\n"> <"\t (cd submodule &&\n"> <"\t git reset --hard HEAD &&\n"> <"\t git submodule update --recursive\n"> <"\t ) &&\n"> <"\t (cd submodule &&\n"> <"\t test_commit \"update_submodule_3\" file\n"> <"\t ) &&\n"> <"\t (cd submodule2 &&\n"> <"\t test_commit \"update_submodule2_3\" file\n"> <"\t ) &&\n"> <"\t git add submodule &&\n"> <"\t git add submodule2 &&\n"> <"\t git commit -m \"two_new_submodule_commits\" &&\n"> <"\t (cd submodule &&\n"> <"\t git checkout master &&\n"> <"\t test_commit \"conflict2\" file &&\n"> <"\t echo \"conflict\" > file\n"> <"\t ) &&\n"> <"\t git checkout HEAD^ &&\n"> <"\t (cd submodule2 &&\n"> <"\t git rev-parse --verify HEAD >../expect\n"> <"\t ) &&\n"> <"\t git config submodule.submodule.update rebase &&\n"> <"\t test_must_fail git submodule update &&\n"> <"\t (cd submodule2 &&\n"> <"\t git rev-parse --verify HEAD >../actual\n"> <"\t ) &&\n"> <"\t test_cmp expect actual\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"add different submodules to the same path">)} { (SQ <"\n"> <"\t(cd super &&\n"> <"\t git submodule add ../submodule s1 &&\n"> <"\t test_must_fail git submodule add ../merging s1\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"submodule add places git-dir in superprojects git-dir">)} { (SQ <"\n"> <"\t(cd super &&\n"> <"\t mkdir deeper &&\n"> <"\t git submodule add ../submodule deeper/submodule &&\n"> <"\t (cd deeper/submodule &&\n"> <"\t git log > ../../expected\n"> <"\t ) &&\n"> <"\t (cd .git/modules/deeper/submodule &&\n"> <"\t git log > ../../../../actual\n"> <"\t ) &&\n"> <"\t test_cmp actual expected\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"submodule update places git-dir in superprojects git-dir">)} { (SQ <"\n"> <"\t(cd super &&\n"> <"\t git commit -m \"added submodule\"\n"> <"\t) &&\n"> <"\tgit clone super super2 &&\n"> <"\t(cd super2 &&\n"> <"\t git submodule init deeper/submodule &&\n"> <"\t git submodule update &&\n"> <"\t (cd deeper/submodule &&\n"> <"\t git log > ../../expected\n"> <"\t ) &&\n"> <"\t (cd .git/modules/deeper/submodule &&\n"> <"\t git log > ../../../../actual\n"> <"\t ) &&\n"> <"\t test_cmp actual expected\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"submodule add places git-dir in superprojects git-dir recursive">)} { (SQ <"\n"> <"\t(cd super2 &&\n"> <"\t (cd deeper/submodule &&\n"> <"\t git submodule add ../submodule subsubmodule &&\n"> <"\t (cd subsubmodule &&\n"> <"\t git log > ../../../expected\n"> <"\t ) &&\n"> <"\t git commit -m \"added subsubmodule\" &&\n"> <"\t git push origin :\n"> <"\t ) &&\n"> <"\t (cd .git/modules/deeper/submodule/modules/subsubmodule &&\n"> <"\t git log > ../../../../../actual\n"> <"\t ) &&\n"> <"\t git add deeper/submodule &&\n"> <"\t git commit -m \"update submodule\" &&\n"> <"\t git push origin : &&\n"> <"\t test_cmp actual expected\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"submodule update places git-dir in superprojects git-dir recursive">)} { (SQ <"\n"> <"\tmkdir super_update_r &&\n"> <"\t(cd super_update_r &&\n"> <"\t git init --bare\n"> <"\t) &&\n"> <"\tmkdir subsuper_update_r &&\n"> <"\t(cd subsuper_update_r &&\n"> <"\t git init --bare\n"> <"\t) &&\n"> <"\tmkdir subsubsuper_update_r &&\n"> <"\t(cd subsubsuper_update_r &&\n"> <"\t git init --bare\n"> <"\t) &&\n"> <"\tgit clone subsubsuper_update_r subsubsuper_update_r2 &&\n"> <"\t(cd subsubsuper_update_r2 &&\n"> <"\t test_commit \"update_subsubsuper\" file &&\n"> <"\t git push origin master\n"> <"\t) &&\n"> <"\tgit clone subsuper_update_r subsuper_update_r2 &&\n"> <"\t(cd subsuper_update_r2 &&\n"> <"\t test_commit \"update_subsuper\" file &&\n"> <"\t git submodule add ../subsubsuper_update_r subsubmodule &&\n"> <"\t git commit -am \"subsubmodule\" &&\n"> <"\t git push origin master\n"> <"\t) &&\n"> <"\tgit clone super_update_r super_update_r2 &&\n"> <"\t(cd super_update_r2 &&\n"> <"\t test_commit \"update_super\" file &&\n"> <"\t git submodule add ../subsuper_update_r submodule &&\n"> <"\t git commit -am \"submodule\" &&\n"> <"\t git push origin master\n"> <"\t) &&\n"> <"\trm -rf super_update_r2 &&\n"> <"\tgit clone super_update_r super_update_r2 &&\n"> <"\t(cd super_update_r2 &&\n"> <"\t git submodule update --init --recursive >actual &&\n"> <"\t test_i18ngrep \"Submodule path .submodule/subsubmodule.: checked out\" actual &&\n"> <"\t (cd submodule/subsubmodule &&\n"> <"\t git log > ../../expected\n"> <"\t ) &&\n"> <"\t (cd .git/modules/submodule/modules/subsubmodule\n"> <"\t git log > ../../../../../actual\n"> <"\t )\n"> <"\t test_cmp actual expected\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"submodule add properly re-creates deeper level submodules">)} { (SQ <"\n"> <"\t(cd super &&\n"> <"\t git reset --hard master &&\n"> <"\t rm -rf deeper/ &&\n"> <"\t git submodule add --force ../submodule deeper/submodule\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"submodule update properly revives a moved submodule">)} { (SQ <"\n"> <"\t(cd super &&\n"> <"\t H=$(git rev-parse --short HEAD) &&\n"> <"\t git commit -am \"pre move\" &&\n"> <"\t H2=$(git rev-parse --short HEAD) &&\n"> <"\t git status | sed \"s/$H/XXX/\" >expect &&\n"> <"\t H=$(cd submodule2; git rev-parse HEAD) &&\n"> <"\t git rm --cached submodule2 &&\n"> <"\t rm -rf submodule2 &&\n"> <"\t mkdir -p \"moved/sub module\" &&\n"> <"\t git update-index --add --cacheinfo 160000 $H \"moved/sub module\" &&\n"> <"\t git config -f .gitmodules submodule.submodule2.path \"moved/sub module\"\n"> <"\t git commit -am \"post move\" &&\n"> <"\t git submodule update &&\n"> <"\t git status | sed \"s/$H2/XXX/\" >actual &&\n"> <"\t test_cmp expect actual\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SYMLINKS)} {(SQ <"submodule update can handle symbolic links in pwd">)} { (SQ <"\n"> <"\tmkdir -p linked/dir &&\n"> <"\tln -s linked/dir linkto &&\n"> <"\t(cd linkto &&\n"> <"\t git clone \"$TRASH_DIRECTORY\"/super_update_r2 super &&\n"> <"\t (cd super &&\n"> <"\t git submodule update --init --recursive\n"> <"\t )\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"submodule update clone shallow submodule">)} { (SQ <"\n"> <"\ttest_when_finished \"rm -rf super3\" &&\n"> <"\tfirst=$(git -C cloned submodule status submodule |cut -c2-41) &&\n"> <"\tsecond=$(git -C submodule rev-parse HEAD) &&\n"> <"\tcommit_count=$(git -C submodule rev-list --count $first^..$second) &&\n"> <"\tgit clone cloned super3 &&\n"> <"\tpwd=$(pwd) &&\n"> <"\t(\n"> <"\t\tcd super3 &&\n"> <"\t\tsed -e \"s#url = ../#url = file://$pwd/#\" <.gitmodules >.gitmodules.tmp &&\n"> <"\t\tmv -f .gitmodules.tmp .gitmodules &&\n"> <"\t\tgit submodule update --init --depth=$commit_count &&\n"> <"\t\ttest 1 = $(git -C submodule log --oneline | wc -l)\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"submodule update clone shallow submodule outside of depth">)} { (SQ <"\n"> <"\ttest_when_finished \"rm -rf super3\" &&\n"> <"\tgit clone cloned super3 &&\n"> <"\tpwd=$(pwd) &&\n"> <"\t(\n"> <"\t\tcd super3 &&\n"> <"\t\tsed -e \"s#url = ../#url = file://$pwd/#\" <.gitmodules >.gitmodules.tmp &&\n"> <"\t\tmv -f .gitmodules.tmp .gitmodules &&\n"> <"\t\ttest_must_fail git submodule update --init --depth=1 2>actual &&\n"> <"\t\ttest_i18ngrep \"Direct fetching of that commit failed.\" actual &&\n"> <"\t\tgit -C ../submodule config uploadpack.allowReachableSHA1InWant true &&\n"> <"\t\tgit submodule update --init --depth=1 >actual &&\n"> <"\t\ttest 1 = $(git -C submodule log --oneline | wc -l)\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"submodule update --recursive drops module name before recursing">)} { (SQ <"\n"> <"\t(cd super2 &&\n"> <"\t (cd deeper/submodule/subsubmodule &&\n"> <"\t git checkout HEAD^\n"> <"\t ) &&\n"> <"\t git submodule update --recursive deeper/submodule >actual &&\n"> < "\t test_i18ngrep \"Submodule path .deeper/submodule/subsubmodule.: checked out\" actual\n" > <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"submodule update can be run in parallel">)} { (SQ <"\n"> <"\t(cd super2 &&\n"> <"\t GIT_TRACE=$(pwd)/trace.out git submodule update --jobs 7 &&\n"> <"\t grep \"7 tasks\" trace.out &&\n"> <"\t git config submodule.fetchJobs 8 &&\n"> <"\t GIT_TRACE=$(pwd)/trace.out git submodule update &&\n"> <"\t grep \"8 tasks\" trace.out &&\n"> <"\t GIT_TRACE=$(pwd)/trace.out git submodule update --jobs 9 &&\n"> <"\t grep \"9 tasks\" trace.out\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"git clone passes the parallel jobs config on to submodules">)} { (SQ <"\n"> <"\ttest_when_finished \"rm -rf super4\" &&\n"> <"\tGIT_TRACE=$(pwd)/trace.out git clone --recurse-submodules --jobs 7 . super4 &&\n"> <"\tgrep \"7 tasks\" trace.out &&\n"> <"\trm -rf super4 &&\n"> <"\tgit config --global submodule.fetchJobs 8 &&\n"> <"\tGIT_TRACE=$(pwd)/trace.out git clone --recurse-submodules . super4 &&\n"> <"\tgrep \"8 tasks\" trace.out &&\n"> <"\trm -rf super4 &&\n"> <"\tGIT_TRACE=$(pwd)/trace.out git clone --recurse-submodules --jobs 9 . super4 &&\n"> <"\tgrep \"9 tasks\" trace.out &&\n"> <"\trm -rf super4\n"> ) } ) (C {(test_done)}) ] )