зеркало из https://github.com/microsoft/git.git
Merge branch 'jk/fsck-dot-in-trees'
* jk/fsck-dot-in-trees: fsck: warn about ".git" in trees fsck: warn about '.' and '..' in trees
This commit is contained in:
Коммит
d65d991b65
15
fsck.c
15
fsck.c
|
@ -142,6 +142,9 @@ static int fsck_tree(struct tree *item, int strict, fsck_error error_func)
|
||||||
int has_null_sha1 = 0;
|
int has_null_sha1 = 0;
|
||||||
int has_full_path = 0;
|
int has_full_path = 0;
|
||||||
int has_empty_name = 0;
|
int has_empty_name = 0;
|
||||||
|
int has_dot = 0;
|
||||||
|
int has_dotdot = 0;
|
||||||
|
int has_dotgit = 0;
|
||||||
int has_zero_pad = 0;
|
int has_zero_pad = 0;
|
||||||
int has_bad_modes = 0;
|
int has_bad_modes = 0;
|
||||||
int has_dup_entries = 0;
|
int has_dup_entries = 0;
|
||||||
|
@ -168,6 +171,12 @@ static int fsck_tree(struct tree *item, int strict, fsck_error error_func)
|
||||||
has_full_path = 1;
|
has_full_path = 1;
|
||||||
if (!*name)
|
if (!*name)
|
||||||
has_empty_name = 1;
|
has_empty_name = 1;
|
||||||
|
if (!strcmp(name, "."))
|
||||||
|
has_dot = 1;
|
||||||
|
if (!strcmp(name, ".."))
|
||||||
|
has_dotdot = 1;
|
||||||
|
if (!strcmp(name, ".git"))
|
||||||
|
has_dotgit = 1;
|
||||||
has_zero_pad |= *(char *)desc.buffer == '0';
|
has_zero_pad |= *(char *)desc.buffer == '0';
|
||||||
update_tree_entry(&desc);
|
update_tree_entry(&desc);
|
||||||
|
|
||||||
|
@ -217,6 +226,12 @@ static int fsck_tree(struct tree *item, int strict, fsck_error error_func)
|
||||||
retval += error_func(&item->object, FSCK_WARN, "contains full pathnames");
|
retval += error_func(&item->object, FSCK_WARN, "contains full pathnames");
|
||||||
if (has_empty_name)
|
if (has_empty_name)
|
||||||
retval += error_func(&item->object, FSCK_WARN, "contains empty pathname");
|
retval += error_func(&item->object, FSCK_WARN, "contains empty pathname");
|
||||||
|
if (has_dot)
|
||||||
|
retval += error_func(&item->object, FSCK_WARN, "contains '.'");
|
||||||
|
if (has_dotdot)
|
||||||
|
retval += error_func(&item->object, FSCK_WARN, "contains '..'");
|
||||||
|
if (has_dotgit)
|
||||||
|
retval += error_func(&item->object, FSCK_WARN, "contains '.git'");
|
||||||
if (has_zero_pad)
|
if (has_zero_pad)
|
||||||
retval += error_func(&item->object, FSCK_WARN, "contains zero-padded file modes");
|
retval += error_func(&item->object, FSCK_WARN, "contains zero-padded file modes");
|
||||||
if (has_bad_modes)
|
if (has_bad_modes)
|
||||||
|
|
|
@ -237,4 +237,35 @@ test_expect_success 'fsck notices submodule entry pointing to null sha1' '
|
||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'fsck notices "." and ".." in trees' '
|
||||||
|
(
|
||||||
|
git init dots &&
|
||||||
|
cd dots &&
|
||||||
|
blob=$(echo foo | git hash-object -w --stdin) &&
|
||||||
|
tab=$(printf "\\t") &&
|
||||||
|
git mktree <<-EOF &&
|
||||||
|
100644 blob $blob$tab.
|
||||||
|
100644 blob $blob$tab..
|
||||||
|
EOF
|
||||||
|
git fsck 2>out &&
|
||||||
|
cat out &&
|
||||||
|
grep "warning.*\\." out
|
||||||
|
)
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'fsck notices ".git" in trees' '
|
||||||
|
(
|
||||||
|
git init dotgit &&
|
||||||
|
cd dotgit &&
|
||||||
|
blob=$(echo foo | git hash-object -w --stdin) &&
|
||||||
|
tab=$(printf "\\t") &&
|
||||||
|
git mktree <<-EOF &&
|
||||||
|
100644 blob $blob$tab.git
|
||||||
|
EOF
|
||||||
|
git fsck 2>out &&
|
||||||
|
cat out &&
|
||||||
|
grep "warning.*\\.git" out
|
||||||
|
)
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|
Загрузка…
Ссылка в новой задаче