Re: [PATCH v5 6/6] remove_subtree(): test removing nested directories
From: Michael Haggerty <hidden>
Date: 2017-03-30 11:07:20
On 03/30/2017 05:32 AM, Daniel Ferreira wrote:
quoted hunk ↗ jump to hunk
Test removing a nested directory when an attempt is made to restore the index to a state where it does not exist. A similar test could be found previously in t/t2000-checkout-cache-clash.sh, but it did not check for nested directories, which could allow a faulty implementation of remove_subtree() pass the tests. Signed-off-by: Daniel Ferreira <redacted> --- t/t2000-checkout-cache-clash.sh | 11 +++++++++++ 1 file changed, 11 insertions(+)diff --git a/t/t2000-checkout-cache-clash.sh b/t/t2000-checkout-cache-clash.sh index de3edb5..ac10ba3 100755 --- a/t/t2000-checkout-cache-clash.sh +++ b/t/t2000-checkout-cache-clash.sh@@ -57,4 +57,15 @@ test_expect_success SYMLINKS 'checkout-index -f twice with --prefix' ' git checkout-index -a -f --prefix=there/ ' +test_expect_success 'git checkout-index -f should remove nested subtrees' ' + echo content >path && + git update-index --add path && + rm path && + mkdir -p path/with/nested/paths && + echo content >path/file1 && + echo content >path/with/nested/paths/file2 && + git checkout-index -f -a && + test ! -d path +' + test_done
It would be better for this patch to precede "remove_subtree(): reimplement using iterators", as a slightly better proof that the change to using iterators doesn't change the behavior. Michael