Skip to content

Commit 7ba4626

Browse files
committed
Merge branch 'maint-2.1' into maint
* maint-2.1: is_hfs_dotgit: loosen over-eager match of \u{..47}
2 parents c2e8e4b + 3c84ac8 commit 7ba4626

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
@@ -345,6 +345,21 @@ dot-backslash-case .\\\\.GIT\\\\foobar
345345
dotgit-case-backslash .git\\\\foobar
346346
EOF
347347

348+
test_expect_success 'fsck allows .Ňit' '
349+
(
350+
git init not-dotgit &&
351+
cd not-dotgit &&
352+
echo content >file &&
353+
git add file &&
354+
git commit -m base &&
355+
blob=$(git rev-parse :file) &&
356+
printf "100644 blob $blob\t.\\305\\207it" >tree &&
357+
tree=$(git mktree <tree) &&
358+
git fsck 2>err &&
359+
test_line_count = 0 err
360+
)
361+
'
362+
348363
# create a static test repo which is broken by omitting
349364
# one particular object ($1, which is looked up via rev-parse
350365
# in the new repository).

utf8.c

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

565565
/*
566-
* Pick the next char from the stream, folding as an HFS+ filename comparison
567-
* would. Note that this is _not_ complete by any means. It's just enough
566+
* Pick the next char from the stream, ignoring codepoints an HFS+ would.
567+
* Note that this is _not_ complete by any means. It's just enough
568568
* to make is_hfs_dotgit() work, and should not be used otherwise.
569569
*/
570570
static ucs_char_t next_hfs_char(const char **in)
@@ -601,23 +601,31 @@ static ucs_char_t next_hfs_char(const char **in)
601601
continue;
602602
}
603603

604-
/*
605-
* there's a great deal of other case-folding that occurs,
606-
* but this is enough to catch anything that will convert
607-
* to ".git"
608-
*/
609-
return tolower(out);
604+
return out;
610605
}
611606
}
612607

613608
int is_hfs_dotgit(const char *path)
614609
{
615610
ucs_char_t c;
616611

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

0 commit comments

Comments
 (0)