Subject: Re: [PATCH] t: add clone test for files differing only in case

From: Eric Sunshine <[email-masked]>
Date: Sun, 21 Jan 2018 03:07:28 -0500

On Sun, Jan 21, 2018 at 02:46:15AM -0500, Eric Sunshine wrote:
> On Sun, Jan 21, 2018 at 2:33 AM, Junio C Hamano <[email-masked]> wrote:
> > "brian m. carlson" <[email-masked]> writes:
> >> +test_expect_success 'clone on case-insensitive fs' '
> >> +     o=$(git hash-object -w --stdin </dev/null | hex2oct) &&
> >> +     t=$(printf "100644 X\0${o}100644 x\0${o}" |
> >> +             git hash-object -w -t tree --stdin) &&
> >> +     c=$(git commit-tree -m bogus $t) &&
> >> +     git update-ref refs/heads/bogus $c &&
> >> +     git clone -b bogus . bogus
> >> +'
> >
> > Hmm, I seem to be seeing a failure from this thing:
> >     fatal: repository '.' does not exist
> > even on a case sensitive platform.
> 
> Yep. In pretty much any other test script, this would work (it was
> developed in a stand-alone script), but t5601 (which nukes .git as its
> first action) isn't the most friendly place.

Here's a re-roll which fixes that problem (and has a slightly
re-written commit message.

--- >8 ---
From: Eric Sunshine <[email-masked]>
Subject: [PATCH] t5601-clone: test case-conflicting files on case-insensitive
 filesystem

A recently introduced regression caused a segfault at clone time on
case-insensitive filesystems when filenames differing only in case are
present. This bug has already been fixed (repository: pre-initialize
hash algo pointer, 2018-01-18), but it's not the first time similar
problems have arisen. Therefore, introduce a test to catch this case and
protect against future regressions.

Signed-off-by: Eric Sunshine <[email-masked]>
Signed-off-by: brian m. carlson <[email-masked]>
Signed-off-by: Eric Sunshine <[email-masked]>
---
 t/t5601-clone.sh | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh
index 0f895478f0..2d1490f631 100755
--- a/t/t5601-clone.sh
+++ b/t/t5601-clone.sh
@@ -611,4 +611,21 @@ test_expect_success 'GIT_TRACE_PACKFILE produces a usable pack' '
 	git -C replay.git index-pack -v --stdin <tmp.pack
 '
 
+hex2oct() {
+	perl -ne 'printf "\\%03o", hex for /../g'
+}
+
+test_expect_success 'clone on case-insensitive fs' '
+	git init icasefs &&
+	(
+		cd icasefs
+		o=$(git hash-object -w --stdin </dev/null | hex2oct) &&
+		t=$(printf "100644 X\0${o}100644 x\0${o}" |
+			git hash-object -w -t tree --stdin) &&
+		c=$(git commit-tree -m bogus $t) &&
+		git update-ref refs/heads/bogus $c &&
+		git clone -b bogus . bogus
+	)
+'
+
 test_done
-- 
2.16.0.312.g896df04e46