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

Re: [PATCH] apply: support case-only renames in case-insensitive filesystems

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 13, 2022, 18:12 UTC
Message-ID
<xmqqo7yw77qo.fsf@gitster.g>
In-Reply-To
<xmqqr13t8np7.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
Show 6 quoted lines
> And then, you could use --cached (not --index) to bypass the working
> tree altogether, which is a good way to test the feature without
> getting affected by the underlying filesystem.  Check both case
> sensitive and case insensitive cases:
> ...
> Likewise, try both sensitive and insensitive one.
As I already wrote tests for basic cases, I'm sending them out,

so that you may extend them with your new cases so that new code you write can be checked.

Thanks.
----- >8 --------- >8 --------- >8 --------- >8 --------- >8 -----
From: Junio C Hamano <gitster@pobox.com>
Date: Mon, 13 Jun 2022 11:05:54 -0700
Subject: [PATCH] t4141: test "git apply" with core.ignorecase
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 t/t4141-apply-icase.sh | 128 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 128 insertions(+)
 create mode 100755 t/t4141-apply-icase.sh
diff --git a/t/t4141-apply-icase.sh b/t/t4141-apply-icase.sh
new file mode 100755
index 0000000000..9b70ff82c3
--- /dev/null
+++ b/t/t4141-apply-icase.sh
@@ -0,0 +1,128 @@
+#!/bin/sh
+
+test_description='git apply with core.ignorecase'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+	# initial commit has file0 only
+	test_commit "initial" file0 "initial commit with file0" initial &&
+
+	# current commit has file1 as well
+	test_commit "current" file1 "initial content of file1" current &&
+	file0blob=$(git rev-parse :file0) &&
+	file1blob=$(git rev-parse :file1) &&
+
+	# prepare sample patches
+	# file0 is modified
+	echo modification to file0 >file0 &&
+	git add file0 &&
+	modifiedfile0blob=$(git rev-parse :file0) &&
+
+	# file1 is removed and then ...
+	git rm --cached file1 &&
+	# ... identical copies are placed at File1 and file2
+	git update-index --add --cacheinfo 100644,$file1blob,file2 &&
+	git update-index --add --cacheinfo 100644,$file1blob,File1 &&
+
+	# then various patches to do basic things
+	git diff HEAD^ HEAD -- file1 >creation-patch &&
+	git diff HEAD HEAD^ -- file1 >deletion-patch &&
+	git diff --cached HEAD -- file1 file2 >rename-file1-to-file2-patch &&
+	git diff --cached HEAD -- file1 File1 >rename-file1-to-File1-patch &&
+	git diff --cached HEAD -- file0 >modify-file0-patch
+'
+
+# Basic creation, deletion, modification and renaming.
+test_expect_success 'creation and deletion' '
+	# start at "initial" with file0 only
+	git reset --hard initial &&
+
+	# add file1
+	git -c core.ignorecase=false apply --cached creation-patch &&
+	test_cmp_rev :file1 "$file1blob" &&
+
+	# remove file1
+	git -c core.ignorecase=false apply --cached deletion-patch &&
+	test_must_fail git rev-parse --verify :file1 &&
+
+	# do the same with ignorecase
+	git -c core.ignorecase=true apply --cached creation-patch &&
+	test_cmp_rev :file1 "$file1blob" &&
+	git -c core.ignorecase=true apply --cached deletion-patch &&
+	test_must_fail git rev-parse --verify :file1
+'
+
+test_expect_success 'modificaiton' '
+	# start at "initial" with file0 only
+	git reset --hard initial &&
+
+	# modify file0
+	git -c core.ignorecase=false apply --cached modify-file0-patch &&
+	test_cmp_rev :file0 "$modifiedfile0blob" &&
+	git -c core.ignorecase=false apply --cached -R modify-file0-patch &&
+	test_cmp_rev :file0 "$file0blob" &&
+
+	# do the same with ignorecase
+	git -c core.ignorecase=true apply --cached modify-file0-patch &&
+	test_cmp_rev :file0 "$modifiedfile0blob" &&
+	git -c core.ignorecase=true apply --cached -R modify-file0-patch &&
+	test_cmp_rev :file0 "$file0blob"
+'
+
+test_expect_success 'rename file1 to file2' '
+	# start from file0 and file1
+	git reset --hard current &&
+
+	# rename file1 to file2
+	git -c core.ignorecase=false apply --cached rename-file1-to-file2-patch &&
+	test_must_fail git rev-parse --verify :file1 &&
+	test_cmp_rev :file2 "$file1blob" &&
+	git -c core.ignorecase=false apply --cached -R rename-file1-to-file2-patch &&
+	test_must_fail git rev-parse --verify :file2 &&
+	test_cmp_rev :file1 "$file1blob" &&
+
+	# do the same with ignorecase
+	git -c core.ignorecase=true apply --cached rename-file1-to-file2-patch &&
+	test_must_fail git rev-parse --verify :file1 &&
+	test_cmp_rev :file2 "$file1blob" &&
+	git -c core.ignorecase=true apply --cached -R rename-file1-to-file2-patch &&
+	test_must_fail git rev-parse --verify :file2 &&
+	test_cmp_rev :file1 "$file1blob"
+'
+
+test_expect_success 'rename file1 to file2' '
+	# start from file0 and file1
+	git reset --hard current &&
+
+	# rename file1 to File1
+	git -c core.ignorecase=false apply --cached rename-file1-to-File1-patch &&
+	test_must_fail git rev-parse --verify :file1 &&
+	test_cmp_rev :File1 "$file1blob" &&
+	git -c core.ignorecase=false apply --cached -R rename-file1-to-File1-patch &&
+	test_must_fail git rev-parse --verify :File1 &&
+	test_cmp_rev :file1 "$file1blob" &&
+
+	# do the same with ignorecase
+	git -c core.ignorecase=true apply --cached rename-file1-to-File1-patch &&
+	test_must_fail git rev-parse --verify :file1 &&
+	test_cmp_rev :File1 "$file1blob" &&
+	git -c core.ignorecase=true apply --cached -R rename-file1-to-File1-patch &&
+	test_must_fail git rev-parse --verify :File1 &&
+	test_cmp_rev :file1 "$file1blob"
+'
+
+# We may want to add tests with working tree here, without "--cached" and
+# with and without "--index" here.  For example, should modify-file0-patch
+# apply cleanly if we have File0 with $file0blob in the index and the working
+# tree if core.icase is set?
+
+test_expect_success CASE_INSENSITIVE_FS 'a test only for icase fs' '
+	: sample
+'
+
+test_expect_success !CASE_INSENSITIVE_FS 'a test only for !icase fs' '
+	: sample
+'
+
+test_done
-- 
2.36.1-513-gd2306e2395
Previous: Junio C HamanoNext: Tao Klerks
Message 10 of 21 in “apply: support case-only renames in case-insensitive filesystems”
  1. apply: support case-only renames in case-insensitive filesystemsTao Klerks via GitGitGadget, Jun 11, 2022
  2. Junio C HamanoJun 11, 2022
  3. Junio C HamanoJun 12, 2022
  4. Tao KlerksJun 14, 2022
  5. Tao KlerksJun 15, 2022
  6. Tao KlerksJun 14, 2022
  7. Junio C HamanoJun 18, 2022
  8. Tao KlerksJun 18, 2022
  9. Junio C HamanoJun 12, 2022
  10. Junio C HamanoJun 13, 2022
  11. Tao KlerksJun 14, 2022
  12. Tao KlerksJun 14, 2022
  13. 0/3 RFC: apply: support case-only renames in case-insensitive filesystemsTao Klerks via GitGitGadget, Jun 19, 2022
  14. 2/3 reset: new failing test for reset of case-insensitive duplicate in indexTao Klerks via GitGitGadget, Jun 19, 2022
  15. 1/3 t4141: test "git apply" with core.ignorecaseJunio C Hamano via GitGitGadget, Jun 19, 2022
  16. 3/3 apply: support case-only renames in case-insensitive filesystemsTao Klerks via GitGitGadget, Jun 19, 2022
  17. Tao KlerksOct 10, 2022
  18. 0/3 apply: support case-only renames in case-insensitive filesystemsTao Klerks via GitGitGadget, May 28, 2023
  19. 2/3 reset: new failing test for reset of case-insensitive duplicate in indexTao Klerks via GitGitGadget, May 28, 2023
  20. 1/3 t4142: test "git apply" with core.ignorecaseJunio C Hamano via GitGitGadget, May 28, 2023
  21. 3/3 apply: support case-only renames in case-insensitive filesystemsTao Klerks via GitGitGadget, May 28, 2023

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.