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

[PATCH] Add test cases for handling of name conflicts between files and directories.

From
koreth@midwinter.com <koreth@midwinter.com>
Date
Mar 17, 2007, 00:00 UTC
Message-ID
<20070317000004.GA14919@midwinter.com>
Here are a few test cases for the file/directory name conflict patch.
---
 t/t7201-co.sh |   70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 70 insertions(+), 0 deletions(-)
diff --git a/t/t7201-co.sh b/t/t7201-co.sh
index 867bbd2..6692f25 100755
--- a/t/t7201-co.sh
+++ b/t/t7201-co.sh
@@ -36,6 +36,9 @@ test_expect_success setup '
 	git update-index --add --remove one two three &&
 	git commit -m "Side M one, D two, A three" &&
 
+	git branch with-file master &&
+	git branch with-dir master &&
+
 	git checkout master
 '
 
@@ -129,4 +132,71 @@ test_expect_success 'checkout -m with merge conflict' '
 	! test -s current
 '
 
+test_expect_success 'checkout with file/directory conflict' '
+
+	git checkout -f with-dir && git clean &&
+
+	mv one one- &&
+	mkdir one &&
+	mv one- one/file &&
+	git add one/file &&
+	git commit -m "with-dir D one A one/file" &&
+	
+	git checkout with-file &&
+	git checkout with-dir
+'
+
+test_expect_success 'checkout with file/directory conflict and modified file in dir' '
+
+	git checkout -f with-dir && git-clean &&
+
+	fill 1 2 3 4 5 6 7 > one/file &&
+	if git checkout with-file
+	then
+		echo Should have detected modified file in subdirectory
+		false
+	else
+		echo "happy - failed correctly"
+	fi
+'
+
+test_expect_success 'checkout with file/directory conflict and untracked file in dir' '
+
+	git checkout -f with-dir && git-clean &&
+
+	fill 1 2 3 > one/file2 &&
+	if git checkout with-file
+	then
+		echo Should have detected untracked file in subdirectory
+		false
+	else
+		echo "happy - failed correctly"
+	fi &&
+	rm one/file2
+'
+
+test_expect_success 'checkout with file/directory conflict and deleted file in dir' '
+
+	git checkout -f with-dir && git-clean &&
+
+	rm one/file &&
+	git checkout with-file
+'
+
+test_expect_success 'checkout with file/directory conflict and modified file' '
+
+	git checkout -f with-file && git-clean &&
+
+	fill 1 2 3 > one &&
+	if git checkout with-dir
+	then
+		echo Should have detected modified file
+		false
+	else
+		echo "happy - failed correctly"
+	fi &&
+
+	git reset --hard
+'
+
 test_done
-- 
1.5.0.4.404.gdbb2-dirty
Message 1 of 1 in “Add test cases for handling of name conflicts between files and directories.”
  1. Add test cases for handling of name conflicts between files and directories.koreth@midwinter.com, Mar 17, 2007

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.