From 24a49cf78eef2a13bc3f7c730e236d58b5e2ebbe Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Mon, 27 Feb 2023 15:28:08 +0000 Subject: t2021: fix platform-specific leftover cruft t2021.6 existed to test the status of a symlink that was left around by previous tests. It tried to also clean up the symlink after it was done so that subsequent tests wouldn't be tripped up by it. Unfortunately, since this test had a SYMLINK prerequisite, that made the cleanup platform dependent...and made a testcase I was trying to add to this testsuite fail (that testcase will be included in the next patch). Before we go and add new testcases, fix this cleanup by moving it into a separate test. Signed-off-by: Elijah Newren Signed-off-by: Junio C Hamano --- t/t2021-checkout-overwrite.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 't') diff --git a/t/t2021-checkout-overwrite.sh b/t/t2021-checkout-overwrite.sh index 713c3fa603..baca66e1a3 100755 --- a/t/t2021-checkout-overwrite.sh +++ b/t/t2021-checkout-overwrite.sh @@ -50,10 +50,13 @@ test_expect_success 'checkout commit with dir must not remove untracked a/b' ' test_expect_success SYMLINKS 'the symlink remained' ' - test_when_finished "rm a/b" && test -h a/b ' +test_expect_success 'cleanup after previous symlink tests' ' + rm a/b +' + test_expect_success SYMLINKS 'checkout -f must not follow symlinks when removing entries' ' git checkout -f start && mkdir dir && -- cgit v1.2.3 From b413a827126abd54fa95470be7c63fa4f00d5d47 Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Mon, 27 Feb 2023 15:28:09 +0000 Subject: unpack-trees: heed requests to overwrite ignored files When a directory exists but has only ignored files within it and we are trying to switch to a branch that has a file where that directory is, the behavior depends upon --[no]-overwrite-ignore. If the user wants to --overwrite-ignore (the default), then we should delete the ignored file and directory and switch to the new branch. The code to handle this in verify_clean_subdirectory() in unpack-trees tried to handle this via paying attention to the exclude_per_dir setting of the internal dir field. This came from commit c81935348b ("Fix switching to a branch with D/F when current branch has file D.", 2007-03-15), which pre-dated 039bc64e88 ("core.excludesfile clean-up", 2007-11-14), and thus did not pay attention to ignore patterns from other relevant files. Change it to use setup_standard_excludes() so that it is also aware of excludes specified in other locations. Signed-off-by: Elijah Newren Signed-off-by: Junio C Hamano --- t/t2021-checkout-overwrite.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 't') diff --git a/t/t2021-checkout-overwrite.sh b/t/t2021-checkout-overwrite.sh index baca66e1a3..034f62c13c 100755 --- a/t/t2021-checkout-overwrite.sh +++ b/t/t2021-checkout-overwrite.sh @@ -69,4 +69,15 @@ test_expect_success SYMLINKS 'checkout -f must not follow symlinks when removing test_path_is_file untracked/f ' +test_expect_success 'checkout --overwrite-ignore should succeed if only ignored files in the way' ' + git checkout -b df_conflict && + test_commit contents some_dir && + git checkout start && + mkdir some_dir && + echo autogenerated information >some_dir/ignore && + echo ignore >.git/info/exclude && + git checkout --overwrite-ignore df_conflict && + ! test_path_is_dir some_dir +' + test_done -- cgit v1.2.3