Merge branch 'jk/submodule-fsck-loose-fixup'

Finishing touches to a topic that already is in 'maint'.

* jk/submodule-fsck-loose-fixup:
  fsck: avoid looking at NULL blob->object
  t7415: don't bother creating commit for symlink test
This commit is contained in:
Junio C Hamano 2018-06-13 12:50:44 -07:00
commit fb6ac9e79a
2 changed files with 24 additions and 8 deletions

3
fsck.c
View File

@ -1036,7 +1036,8 @@ int fsck_finish(struct fsck_options *options)
blob = lookup_blob(oid); blob = lookup_blob(oid);
if (!blob) { if (!blob) {
ret |= report(options, &blob->object, struct object *obj = lookup_unknown_object(oid->hash);
ret |= report(options, obj,
FSCK_MSG_GITMODULES_BLOB, FSCK_MSG_GITMODULES_BLOB,
"non-blob found at .gitmodules"); "non-blob found at .gitmodules");
continue; continue;

View File

@ -135,13 +135,10 @@ test_expect_success 'fsck detects symlinked .gitmodules file' '
tricky="[foo]bar=true" && tricky="[foo]bar=true" &&
content=$(git hash-object -w ../.gitmodules) && content=$(git hash-object -w ../.gitmodules) &&
target=$(printf "$tricky" | git hash-object -w --stdin) && target=$(printf "$tricky" | git hash-object -w --stdin) &&
tree=$(
{ {
printf "100644 blob $content\t$tricky\n" && printf "100644 blob $content\t$tricky\n" &&
printf "120000 blob $target\t.gitmodules\n" printf "120000 blob $target\t.gitmodules\n"
} | git mktree } | git mktree &&
) &&
commit=$(git commit-tree $tree) &&
# Check not only that we fail, but that it is due to the # Check not only that we fail, but that it is due to the
# symlink detector; this grep string comes from the config # symlink detector; this grep string comes from the config
@ -151,4 +148,22 @@ test_expect_success 'fsck detects symlinked .gitmodules file' '
) )
' '
test_expect_success 'fsck detects non-blob .gitmodules' '
git init non-blob &&
(
cd non-blob &&
# As above, make the funny tree directly to avoid index
# restrictions.
mkdir subdir &&
cp ../.gitmodules subdir/file &&
git add subdir/file &&
git commit -m ok &&
git ls-tree HEAD | sed s/subdir/.gitmodules/ | git mktree &&
test_must_fail git fsck 2>output &&
grep gitmodulesBlob output
)
'
test_done test_done