зеркало из https://github.com/microsoft/git.git
fsck: complain about HFS+ ".git" aliases in trees
Now that the index can block pathnames that case-fold to ".git" on HFS+, it would be helpful for fsck to notice such problematic paths. This lets servers which use receive.fsckObjects block them before the damage spreads. Note that the fsck check is always on, even for systems without core.protectHFS set. This is technically more restrictive than we need to be, as a set of users on ext4 could happily use these odd filenames without caring about HFS+. However, on balance, it's helpful for all servers to block these (because the paths can be used for mischief, and servers which bother to fsck would want to stop the spread whether they are on HFS+ themselves or not), and hardly anybody will be affected (because the blocked names are variants of .git with invisible Unicode code-points mixed in, meaning mischief is almost certainly what the tree author had in mind). Ideally these would be controlled by a separate "fsck.protectHFS" flag. However, it would be much nicer to be able to enable/disable _any_ fsck flag individually, and any scheme we choose should match such a system. Given the likelihood of anybody using such a path in practice, it is not unreasonable to wait until such a system materializes. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Родитель
a42643aa8d
Коммит
a18fcc9ff2
3
fsck.c
3
fsck.c
|
@ -6,6 +6,7 @@
|
|||
#include "commit.h"
|
||||
#include "tag.h"
|
||||
#include "fsck.h"
|
||||
#include "utf8.h"
|
||||
|
||||
static int fsck_walk_tree(struct tree *tree, fsck_walk_func walk, void *data)
|
||||
{
|
||||
|
@ -175,7 +176,7 @@ static int fsck_tree(struct tree *item, int strict, fsck_error error_func)
|
|||
has_dot = 1;
|
||||
if (!strcmp(name, ".."))
|
||||
has_dotdot = 1;
|
||||
if (!strcasecmp(name, ".git"))
|
||||
if (!strcasecmp(name, ".git") || is_hfs_dotgit(name))
|
||||
has_dotgit = 1;
|
||||
has_zero_pad |= *(char *)desc.buffer == '0';
|
||||
update_tree_entry(&desc);
|
||||
|
|
|
@ -237,9 +237,10 @@ test_expect_success 'fsck notices submodule entry pointing to null sha1' '
|
|||
)
|
||||
'
|
||||
|
||||
while read name path; do
|
||||
while read name path pretty; do
|
||||
while read mode type; do
|
||||
test_expect_success "fsck notices $path as $type" '
|
||||
: ${pretty:=$path}
|
||||
test_expect_success "fsck notices $pretty as $type" '
|
||||
(
|
||||
git init $name-$type &&
|
||||
cd $name-$type &&
|
||||
|
@ -259,11 +260,12 @@ while read name path; do
|
|||
100644 blob
|
||||
040000 tree
|
||||
EOF
|
||||
done <<-\EOF
|
||||
done <<-EOF
|
||||
dot .
|
||||
dotdot ..
|
||||
dotgit .git
|
||||
dotgit-case .GIT
|
||||
dotgit-unicode .gI${u200c}T .gI{u200c}T
|
||||
EOF
|
||||
|
||||
test_done
|
||||
|
|
Загрузка…
Ссылка в новой задаче