Git Mailing List Archive mirror
 help / color / mirror / Atom feed
From: "Junio C Hamano via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Tao Klerks <tao@klerks.biz>, Junio C Hamano <gitster@pobox.com>,
	Johannes Schindelin <johannes.schindelin@gmx.de>,
	Tao Klerks <tao@klerks.biz>, Junio C Hamano <gitster@pobox.com>
Subject: [PATCH v3 1/3] t4142: test "git apply" with core.ignorecase
Date: Sun, 28 May 2023 09:59:57 +0000	[thread overview]
Message-ID: <8ad60943c6670a041e854f574aae98f8ddb38c70.1685267999.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.1257.v3.git.1685267999.gitgitgadget@gmail.com>

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

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 t/t4142-apply-icase.sh | 128 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 128 insertions(+)
 create mode 100755 t/t4142-apply-icase.sh

diff --git a/t/t4142-apply-icase.sh b/t/t4142-apply-icase.sh
new file mode 100755
index 00000000000..17eb023a437
--- /dev/null
+++ b/t/t4142-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
-- 
gitgitgadget


  reply	other threads:[~2023-05-28 10:00 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
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     ` Junio C Hamano via GitGitGadget [this message]
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=8ad60943c6670a041e854f574aae98f8ddb38c70.1685267999.git.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=johannes.schindelin@gmx.de \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).