diff options
author | Elijah Newren <newren@gmail.com> | 2021-12-09 05:08:27 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-12-09 13:33:12 -0800 |
commit | b817e545338cdb737b3deebf4917afb4a18ede57 (patch) | |
tree | c8e6a6039201162361e9919bfe0f4a6480db3ca0 /t | |
parent | setup: introduce startup_info->original_cwd (diff) | |
download | tgif-b817e545338cdb737b3deebf4917afb4a18ede57.tar.xz |
unpack-trees: refuse to remove startup_info->original_cwd
In the past, when a directory needs to be removed to make room for a
file, we have always errored out when that directory contains any
untracked (but not ignored) files. Add an extra condition on that: also
error out if the directory is the current working directory we inherited
from our parent process.
Acked-by: Derrick Stolee <stolee@gmail.com>
Acked-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-x | t/t2501-cwd-empty.sh | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/t/t2501-cwd-empty.sh b/t/t2501-cwd-empty.sh index a05abd1818..398908dfc9 100755 --- a/t/t2501-cwd-empty.sh +++ b/t/t2501-cwd-empty.sh @@ -113,7 +113,7 @@ test_expect_success 'checkout does not clean cwd incidentally' ' ' test_expect_success 'checkout fails if cwd needs to be removed' ' - test_required_dir_removal failure git checkout fd_conflict + test_required_dir_removal success git checkout fd_conflict ' test_expect_success 'reset --hard does not clean cwd incidentally' ' @@ -144,23 +144,17 @@ test_expect_success 'merge fails if cwd needs to be removed; recursive friendly' ( cd dirORfile && - # We would rather this failed, but we test for existing - # rather than desired behavior - git merge fd_conflict 2>../error + test_must_fail git merge fd_conflict 2>../error ) && - ## Here is the behavior we would rather have: - #test_path_is_dir dirORfile && - #grep "Refusing to remove the current working directory" error - ## But instead we test for existing behavior - test_path_is_file dirORfile && - test_must_be_empty error + test_path_is_dir dirORfile && + grep "Refusing to remove the current working directory" error ' GIT_TEST_MERGE_ALGORITHM=ort test_expect_success 'merge fails if cwd needs to be removed' ' - test_required_dir_removal failure git merge fd_conflict + test_required_dir_removal success git merge fd_conflict ' test_expect_success 'cherry-pick does not clean cwd incidentally' ' @@ -168,7 +162,7 @@ test_expect_success 'cherry-pick does not clean cwd incidentally' ' ' test_expect_success 'cherry-pick fails if cwd needs to be removed' ' - test_required_dir_removal failure git cherry-pick fd_conflict + test_required_dir_removal success git cherry-pick fd_conflict ' test_expect_success 'rebase does not clean cwd incidentally' ' @@ -184,7 +178,7 @@ test_expect_success 'revert does not clean cwd incidentally' ' ' test_expect_success 'revert fails if cwd needs to be removed' ' - test_required_dir_removal failure git revert undo_fd_conflict + test_required_dir_removal success git revert undo_fd_conflict ' test_expect_success 'rm does not clean cwd incidentally' ' |