#!/bin/sh global test_description := ''checkout can handle submodules'' source ./test-lib.sh source "$TEST_DIRECTORY"/lib-submodule-update.sh test_expect_success 'setup' ' mkdir submodule && (cd submodule && git init && test_commit first) && git add submodule && test_tick && git commit -m superproject && (cd submodule && test_commit second) && git add submodule && test_tick && git commit -m updated.superproject ' test_expect_success '"reset " updates the index' ' git update-index --refresh && git diff-files --quiet && git diff-index --quiet --cached HEAD && git reset HEAD^ submodule && test_must_fail git diff-files --quiet && git reset submodule && git diff-files --quiet ' test_expect_success '"checkout " updates the index only' ' git update-index --refresh && git diff-files --quiet && git diff-index --quiet --cached HEAD && git checkout HEAD^ submodule && test_must_fail git diff-files --quiet && git checkout HEAD submodule && git diff-files --quiet ' test_expect_success '"checkout " honors diff.ignoreSubmodules' ' git config diff.ignoreSubmodules dirty && echo x> submodule/untracked && git checkout HEAD >actual 2>&1 && ! test -s actual ' test_expect_success '"checkout " honors submodule.*.ignore from .gitmodules' ' git config diff.ignoreSubmodules none && git config -f .gitmodules submodule.submodule.path submodule && git config -f .gitmodules submodule.submodule.ignore untracked && git checkout HEAD >actual 2>&1 && ! test -s actual ' test_expect_success '"checkout " honors submodule.*.ignore from .git/config' ' git config -f .gitmodules submodule.submodule.ignore none && git config submodule.submodule.path submodule && git config submodule.submodule.ignore all && git checkout HEAD >actual 2>&1 && ! test -s actual ' test_submodule_switch "git checkout" test_submodule_forced_switch "git checkout -f" test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"checkout can handle submodules">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (C {(.)} {(DQ ($ VSub_Name "$TEST_DIRECTORY")) (/lib-submodule-update.sh)}) (C {(test_expect_success)} {(SQ )} { (SQ <"\n"> <"\tmkdir submodule &&\n"> <"\t(cd submodule &&\n"> <"\t git init &&\n"> <"\t test_commit first) &&\n"> <"\tgit add submodule &&\n"> <"\ttest_tick &&\n"> <"\tgit commit -m superproject &&\n"> <"\t(cd submodule &&\n"> <"\t test_commit second) &&\n"> <"\tgit add submodule &&\n"> <"\ttest_tick &&\n"> <"\tgit commit -m updated.superproject\n"> ) } ) (C {(test_expect_success)} {(SQ <"\"reset \" updates the index">)} { (SQ <"\n"> <"\tgit update-index --refresh &&\n"> <"\tgit diff-files --quiet &&\n"> <"\tgit diff-index --quiet --cached HEAD &&\n"> <"\tgit reset HEAD^ submodule &&\n"> <"\ttest_must_fail git diff-files --quiet &&\n"> <"\tgit reset submodule &&\n"> <"\tgit diff-files --quiet\n"> ) } ) (C {(test_expect_success)} {(SQ <"\"checkout \" updates the index only">)} { (SQ <"\n"> <"\tgit update-index --refresh &&\n"> <"\tgit diff-files --quiet &&\n"> <"\tgit diff-index --quiet --cached HEAD &&\n"> <"\tgit checkout HEAD^ submodule &&\n"> <"\ttest_must_fail git diff-files --quiet &&\n"> <"\tgit checkout HEAD submodule &&\n"> <"\tgit diff-files --quiet\n"> ) } ) (C {(test_expect_success)} {(SQ <"\"checkout \" honors diff.ignoreSubmodules">)} { (SQ <"\n"> <"\tgit config diff.ignoreSubmodules dirty &&\n"> <"\techo x> submodule/untracked &&\n"> <"\tgit checkout HEAD >actual 2>&1 &&\n"> <"\t! test -s actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"\"checkout \" honors submodule.*.ignore from .gitmodules">)} { (SQ <"\n"> <"\tgit config diff.ignoreSubmodules none &&\n"> <"\tgit config -f .gitmodules submodule.submodule.path submodule &&\n"> <"\tgit config -f .gitmodules submodule.submodule.ignore untracked &&\n"> <"\tgit checkout HEAD >actual 2>&1 &&\n"> <"\t! test -s actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"\"checkout \" honors submodule.*.ignore from .git/config">)} { (SQ <"\n"> <"\tgit config -f .gitmodules submodule.submodule.ignore none &&\n"> <"\tgit config submodule.submodule.path submodule &&\n"> <"\tgit config submodule.submodule.ignore all &&\n"> <"\tgit checkout HEAD >actual 2>&1 &&\n"> <"\t! test -s actual\n"> ) } ) (C {(test_submodule_switch)} {(DQ ("git checkout"))}) (C {(test_submodule_forced_switch)} {(DQ ("git checkout -f"))}) (C {(test_done)}) ] )