git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v11 2/5] remove_subtree(): test removing nested directories

From
Daniel Ferreira <bnmvco@gmail.com>
Date
Apr 26, 2017, 17:03 UTC
Message-ID
<1493226219-33423-3-git-send-email-bnmvco@gmail.com>
In-Reply-To
<1493226219-33423-1-git-send-email-bnmvco@gmail.com>

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 <bnmvco@gmail.com>
---
 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
-- 
2.7.4 (Apple Git-66)
Previous: Daniel FerreiraNext: Daniel Ferreira
Message 3 of 6 in “[GSoC] remove_subtree(): reimplement using iterators”
  1. 0/5 [GSoC] remove_subtree(): reimplement using iteratorsDaniel Ferreira, Apr 26, 2017
  2. 1/5 dir_iterator: add tests for dir_iterator APIDaniel Ferreira, Apr 26, 2017
  3. 2/5 remove_subtree(): test removing nested directoriesDaniel Ferreira, Apr 26, 2017
  4. 3/5 dir_iterator: refactor dir_iterator_advanceDaniel Ferreira, Apr 26, 2017
  5. 4/5 dir_iterator: rewrite state machine modelDaniel Ferreira, Apr 26, 2017
  6. 5/5 remove_subtree(): reimplement using iteratorsDaniel Ferreira, Apr 26, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.