mirror of
https://github.com/git/git.git
synced 2024-11-24 18:33:43 +08:00
ec10b018e7
Using 'test_must_be_empty' is preferable to '! test -s', because it gives a helpful error message if the given file is unexpectedly not empty, while the latter remains completely silent. Furthermore, it also catches cases when the given file unexpectedly does not exist at all. This patch was basically created by: sed -i -e 's/! test -s/test_must_be_empty/' t[0-9]*.sh with the following notable exceptions: - The '! test -s' check in '.gitmodules ignore=dirty suppresses submodules with untracked content' in 't7508-status.sh' is left as-is, because it's bogus and, therefore, it's subject of a dedicated patch. - The '! test -s' checks in 't9131-git-svn-empty-symlink.sh' and 't9135-git-svn-moved-branch-empty-file.sh' are immediately preceeded by a 'test -f' to ensure that the files exist in the first place. 'test_must_be_empty' ensures that as well, so those 'test -f' commands are removed as well. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
76 lines
2.1 KiB
Bash
Executable File
76 lines
2.1 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_must_be_empty 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_must_be_empty 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_must_be_empty actual
|
|
'
|
|
|
|
KNOWN_FAILURE_DIRECTORY_SUBMODULE_CONFLICTS=1
|
|
test_submodule_switch_recursing_with_args "checkout"
|
|
|
|
test_submodule_forced_switch_recursing_with_args "checkout -f"
|
|
|
|
test_submodule_switch "git checkout"
|
|
|
|
test_submodule_forced_switch "git checkout -f"
|
|
|
|
test_done
|