2009-04-02 17:30:25 +04:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test_description='checkout can handle submodules'
|
|
|
|
|
|
|
|
. ./test-lib.sh
|
2014-06-15 20:58:44 +04:00
|
|
|
. "$TEST_DIRECTORY"/lib-submodule-update.sh
|
2009-04-02 17:30:25 +04:00
|
|
|
|
|
|
|
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 <submodule>" updates the index' '
|
|
|
|
git update-index --refresh &&
|
|
|
|
git diff-files --quiet &&
|
|
|
|
git diff-index --quiet --cached HEAD &&
|
2013-01-15 09:47:34 +04:00
|
|
|
git reset HEAD^ submodule &&
|
2009-04-02 17:30:25 +04:00
|
|
|
test_must_fail git diff-files --quiet &&
|
|
|
|
git reset submodule &&
|
|
|
|
git diff-files --quiet
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success '"checkout <submodule>" 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
|
|
|
|
'
|
|
|
|
|
2010-08-28 18:49:25 +04:00
|
|
|
test_expect_success '"checkout <submodule>" honors diff.ignoreSubmodules' '
|
|
|
|
git config diff.ignoreSubmodules dirty &&
|
|
|
|
echo x> submodule/untracked &&
|
|
|
|
git checkout HEAD >actual 2>&1 &&
|
2018-08-20 00:57:22 +03:00
|
|
|
test_must_be_empty actual
|
2010-08-28 18:49:25 +04:00
|
|
|
'
|
|
|
|
|
2010-08-28 18:50:07 +04:00
|
|
|
test_expect_success '"checkout <submodule>" 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 &&
|
2018-08-20 00:57:22 +03:00
|
|
|
test_must_be_empty actual
|
2010-08-28 18:50:07 +04:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success '"checkout <submodule>" 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 &&
|
2018-08-20 00:57:22 +03:00
|
|
|
test_must_be_empty actual
|
2010-08-28 18:50:07 +04:00
|
|
|
'
|
|
|
|
|
2017-03-15 00:46:41 +03:00
|
|
|
KNOWN_FAILURE_DIRECTORY_SUBMODULE_CONFLICTS=1
|
2017-05-26 22:10:11 +03:00
|
|
|
test_submodule_switch_recursing_with_args "checkout"
|
2017-03-15 00:46:41 +03:00
|
|
|
|
2017-05-26 22:10:11 +03:00
|
|
|
test_submodule_forced_switch_recursing_with_args "checkout -f"
|
2017-03-15 00:46:41 +03:00
|
|
|
|
2014-06-15 20:58:44 +04:00
|
|
|
test_submodule_switch "git checkout"
|
|
|
|
|
|
|
|
test_submodule_forced_switch "git checkout -f"
|
|
|
|
|
2009-04-02 17:30:25 +04:00
|
|
|
test_done
|