Skip to content

Commit

Permalink
Merge branch 'maint'
Browse files Browse the repository at this point in the history
* maint:
  is_hfs_dotgit: loosen over-eager match of \u{..47}
  • Loading branch information
gitster committed Jan 7, 2015
2 parents 40d2f38 + 7ba4626 commit ee6e4c7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 12 deletions.
15 changes: 15 additions & 0 deletions t/t1450-fsck.sh
Expand Up @@ -349,6 +349,21 @@ dot-backslash-case .\\\\.GIT\\\\foobar
dotgit-case-backslash .git\\\\foobar
EOF

test_expect_success 'fsck allows .Ňit' '
(
git init not-dotgit &&
cd not-dotgit &&
echo content >file &&
git add file &&
git commit -m base &&
blob=$(git rev-parse :file) &&
printf "100644 blob $blob\t.\\305\\207it" >tree &&
tree=$(git mktree <tree) &&
git fsck 2>err &&
test_line_count = 0 err
)
'

# create a static test repo which is broken by omitting
# one particular object ($1, which is looked up via rev-parse
# in the new repository).
Expand Down
32 changes: 20 additions & 12 deletions utf8.c
Expand Up @@ -563,8 +563,8 @@ int mbs_chrlen(const char **text, size_t *remainder_p, const char *encoding)
}

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

/*
* there's a great deal of other case-folding that occurs,
* but this is enough to catch anything that will convert
* to ".git"
*/
return tolower(out);
return out;
}
}

int is_hfs_dotgit(const char *path)
{
ucs_char_t c;

if (next_hfs_char(&path) != '.' ||
next_hfs_char(&path) != 'g' ||
next_hfs_char(&path) != 'i' ||
next_hfs_char(&path) != 't')
c = next_hfs_char(&path);
if (c != '.')
return 0;
c = next_hfs_char(&path);

/*
* there's a great deal of other case-folding that occurs
* in HFS+, but this is enough to catch anything that will
* convert to ".git"
*/
if (c != 'g' && c != 'G')
return 0;
c = next_hfs_char(&path);
if (c != 'i' && c != 'I')
return 0;
c = next_hfs_char(&path);
if (c != 't' && c != 'T')
return 0;
c = next_hfs_char(&path);
if (c && !is_dir_sep(c))
Expand Down

0 comments on commit ee6e4c7

Please sign in to comment.