Skip to content

Commit 3c84ac8

Browse files
committed
Merge branch 'maint-2.0' into maint-2.1
* maint-2.0: is_hfs_dotgit: loosen over-eager match of \u{..47}
2 parents 8e36a6d + 282616c commit 3c84ac8

File tree

2 files changed

+35
-12
lines changed

2 files changed

+35
-12
lines changed

t/t1450-fsck.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,21 @@ dot-backslash-case .\\\\.GIT\\\\foobar
307307
dotgit-case-backslash .git\\\\foobar
308308
EOF
309309

310+
test_expect_success 'fsck allows .Ňit' '
311+
(
312+
git init not-dotgit &&
313+
cd not-dotgit &&
314+
echo content >file &&
315+
git add file &&
316+
git commit -m base &&
317+
blob=$(git rev-parse :file) &&
318+
printf "100644 blob $blob\t.\\305\\207it" >tree &&
319+
tree=$(git mktree <tree) &&
320+
git fsck 2>err &&
321+
test_line_count = 0 err
322+
)
323+
'
324+
310325
# create a static test repo which is broken by omitting
311326
# one particular object ($1, which is looked up via rev-parse
312327
# in the new repository).

utf8.c

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -567,8 +567,8 @@ int mbs_chrlen(const char **text, size_t *remainder_p, const char *encoding)
567567
}
568568

569569
/*
570-
* Pick the next char from the stream, folding as an HFS+ filename comparison
571-
* would. Note that this is _not_ complete by any means. It's just enough
570+
* Pick the next char from the stream, ignoring codepoints an HFS+ would.
571+
* Note that this is _not_ complete by any means. It's just enough
572572
* to make is_hfs_dotgit() work, and should not be used otherwise.
573573
*/
574574
static ucs_char_t next_hfs_char(const char **in)
@@ -605,23 +605,31 @@ static ucs_char_t next_hfs_char(const char **in)
605605
continue;
606606
}
607607

608-
/*
609-
* there's a great deal of other case-folding that occurs,
610-
* but this is enough to catch anything that will convert
611-
* to ".git"
612-
*/
613-
return tolower(out);
608+
return out;
614609
}
615610
}
616611

617612
int is_hfs_dotgit(const char *path)
618613
{
619614
ucs_char_t c;
620615

621-
if (next_hfs_char(&path) != '.' ||
622-
next_hfs_char(&path) != 'g' ||
623-
next_hfs_char(&path) != 'i' ||
624-
next_hfs_char(&path) != 't')
616+
c = next_hfs_char(&path);
617+
if (c != '.')
618+
return 0;
619+
c = next_hfs_char(&path);
620+
621+
/*
622+
* there's a great deal of other case-folding that occurs
623+
* in HFS+, but this is enough to catch anything that will
624+
* convert to ".git"
625+
*/
626+
if (c != 'g' && c != 'G')
627+
return 0;
628+
c = next_hfs_char(&path);
629+
if (c != 'i' && c != 'I')
630+
return 0;
631+
c = next_hfs_char(&path);
632+
if (c != 't' && c != 'T')
625633
return 0;
626634
c = next_hfs_char(&path);
627635
if (c && !is_dir_sep(c))

0 commit comments

Comments
 (0)