Skip to content

Commit 282616c

Browse files
committed
Merge branch 'maint-1.9' into maint-2.0
* maint-1.9: is_hfs_dotgit: loosen over-eager match of \u{..47}
2 parents 9a8c2b6 + 64a03e9 commit 282616c

File tree

2 files changed

+35
-12
lines changed

2 files changed

+35
-12
lines changed

t/t1450-fsck.sh

+15
Original file line numberDiff line numberDiff line change
@@ -287,4 +287,19 @@ dot-backslash-case .\\\\.GIT\\\\foobar
287287
dotgit-case-backslash .git\\\\foobar
288288
EOF
289289

290+
test_expect_success 'fsck allows .Ňit' '
291+
(
292+
git init not-dotgit &&
293+
cd not-dotgit &&
294+
echo content >file &&
295+
git add file &&
296+
git commit -m base &&
297+
blob=$(git rev-parse :file) &&
298+
printf "100644 blob $blob\t.\\305\\207it" >tree &&
299+
tree=$(git mktree <tree) &&
300+
git fsck 2>err &&
301+
test_line_count = 0 err
302+
)
303+
'
304+
290305
test_done

utf8.c

+20-12
Original file line numberDiff line numberDiff line change
@@ -629,8 +629,8 @@ int mbs_chrlen(const char **text, size_t *remainder_p, const char *encoding)
629629
}
630630

631631
/*
632-
* Pick the next char from the stream, folding as an HFS+ filename comparison
633-
* would. Note that this is _not_ complete by any means. It's just enough
632+
* Pick the next char from the stream, ignoring codepoints an HFS+ would.
633+
* Note that this is _not_ complete by any means. It's just enough
634634
* to make is_hfs_dotgit() work, and should not be used otherwise.
635635
*/
636636
static ucs_char_t next_hfs_char(const char **in)
@@ -667,23 +667,31 @@ static ucs_char_t next_hfs_char(const char **in)
667667
continue;
668668
}
669669

670-
/*
671-
* there's a great deal of other case-folding that occurs,
672-
* but this is enough to catch anything that will convert
673-
* to ".git"
674-
*/
675-
return tolower(out);
670+
return out;
676671
}
677672
}
678673

679674
int is_hfs_dotgit(const char *path)
680675
{
681676
ucs_char_t c;
682677

683-
if (next_hfs_char(&path) != '.' ||
684-
next_hfs_char(&path) != 'g' ||
685-
next_hfs_char(&path) != 'i' ||
686-
next_hfs_char(&path) != 't')
678+
c = next_hfs_char(&path);
679+
if (c != '.')
680+
return 0;
681+
c = next_hfs_char(&path);
682+
683+
/*
684+
* there's a great deal of other case-folding that occurs
685+
* in HFS+, but this is enough to catch anything that will
686+
* convert to ".git"
687+
*/
688+
if (c != 'g' && c != 'G')
689+
return 0;
690+
c = next_hfs_char(&path);
691+
if (c != 'i' && c != 'I')
692+
return 0;
693+
c = next_hfs_char(&path);
694+
if (c != 't' && c != 'T')
687695
return 0;
688696
c = next_hfs_char(&path);
689697
if (c && !is_dir_sep(c))

0 commit comments

Comments
 (0)