All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Tao Klerks via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Tao Klerks <tao@klerks.biz>
Subject: Re: [PATCH] apply: support case-only renames in case-insensitive filesystems
Date: Mon, 13 Jun 2022 11:12:31 -0700	[thread overview]
Message-ID: <xmqqo7yw77qo.fsf@gitster.g> (raw)
In-Reply-To: <xmqqr13t8np7.fsf@gitster.g> (Junio C. Hamano's message of "Sun, 12 Jun 2022 16:30:12 -0700")

Junio C Hamano <gitster@pobox.com> writes:

> 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


  reply	other threads:[~2022-06-13 19:42 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-11 17:03 [PATCH] apply: support case-only renames in case-insensitive filesystems Tao Klerks via GitGitGadget
2022-06-11 19:17 ` Junio C Hamano
2022-06-12 23:35   ` Junio C Hamano
2022-06-14  6:22     ` Tao Klerks
2022-06-15 11:24       ` Tao Klerks
2022-06-14  5:13   ` Tao Klerks
2022-06-18  0:45     ` Junio C Hamano
2022-06-18 15:34       ` Tao Klerks
2022-06-12 23:30 ` Junio C Hamano
2022-06-13 18:12   ` Junio C Hamano [this message]
2022-06-14  6:26     ` Tao Klerks
2022-06-14  6:16   ` Tao Klerks
2022-06-19 16:10 ` [PATCH v2 0/3] RFC: " Tao Klerks via GitGitGadget
2022-06-19 16:10   ` [PATCH v2 1/3] t4141: test "git apply" with core.ignorecase Junio C Hamano via GitGitGadget
2022-06-19 16:10   ` [PATCH v2 2/3] reset: new failing test for reset of case-insensitive duplicate in index Tao Klerks via GitGitGadget
2022-06-19 16:10   ` [PATCH v2 3/3] apply: support case-only renames in case-insensitive filesystems Tao Klerks via GitGitGadget
2022-10-10  4:09   ` [PATCH v2 0/3] RFC: " Tao Klerks
2023-05-28  9:59   ` [PATCH v3 0/3] " Tao Klerks via GitGitGadget
2023-05-28  9:59     ` [PATCH v3 1/3] t4142: test "git apply" with core.ignorecase Junio C Hamano via GitGitGadget
2023-05-28  9:59     ` [PATCH v3 2/3] reset: new failing test for reset of case-insensitive duplicate in index Tao Klerks via GitGitGadget
2023-05-28  9:59     ` [PATCH v3 3/3] apply: support case-only renames in case-insensitive filesystems Tao Klerks via GitGitGadget

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqo7yw77qo.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=tao@klerks.biz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.