1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-06-06 02:06:25 +02:00
git/t/t2013-checkout-submodule.sh
Jens Lehmann d78ecca520 checkout: call the new submodule update test framework
Test that the checkout command updates the work tree as expected with
and without the '-f' flag.

Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-07-14 12:06:15 -07:00

71 lines
1.9 KiB
Bash
Executable File

#!/bin/sh
test_description='checkout can handle submodules'
. ./test-lib.sh
. "$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 <submodule>" 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 <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
'
test_expect_success '"checkout <submodule>" 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 <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 &&
! test -s actual
'
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 &&
! test -s actual
'
test_submodule_switch "git checkout"
test_submodule_forced_switch "git checkout -f"
test_done