Skip to content

Commit fb6ac9e

Browse files
committed
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
2 parents b2453d3 + 47cc913 commit fb6ac9e

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

fsck.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,8 @@ int fsck_finish(struct fsck_options *options)
10361036

10371037
blob = lookup_blob(oid);
10381038
if (!blob) {
1039-
ret |= report(options, &blob->object,
1039+
struct object *obj = lookup_unknown_object(oid->hash);
1040+
ret |= report(options, obj,
10401041
FSCK_MSG_GITMODULES_BLOB,
10411042
"non-blob found at .gitmodules");
10421043
continue;

t/t7415-submodule-names.sh

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,10 @@ test_expect_success 'fsck detects symlinked .gitmodules file' '
135135
tricky="[foo]bar=true" &&
136136
content=$(git hash-object -w ../.gitmodules) &&
137137
target=$(printf "$tricky" | git hash-object -w --stdin) &&
138-
tree=$(
139-
{
140-
printf "100644 blob $content\t$tricky\n" &&
141-
printf "120000 blob $target\t.gitmodules\n"
142-
} | git mktree
143-
) &&
144-
commit=$(git commit-tree $tree) &&
138+
{
139+
printf "100644 blob $content\t$tricky\n" &&
140+
printf "120000 blob $target\t.gitmodules\n"
141+
} | git mktree &&
145142
146143
# Check not only that we fail, but that it is due to the
147144
# symlink detector; this grep string comes from the config
@@ -151,4 +148,22 @@ test_expect_success 'fsck detects symlinked .gitmodules file' '
151148
)
152149
'
153150

151+
test_expect_success 'fsck detects non-blob .gitmodules' '
152+
git init non-blob &&
153+
(
154+
cd non-blob &&
155+
156+
# As above, make the funny tree directly to avoid index
157+
# restrictions.
158+
mkdir subdir &&
159+
cp ../.gitmodules subdir/file &&
160+
git add subdir/file &&
161+
git commit -m ok &&
162+
git ls-tree HEAD | sed s/subdir/.gitmodules/ | git mktree &&
163+
164+
test_must_fail git fsck 2>output &&
165+
grep gitmodulesBlob output
166+
)
167+
'
168+
154169
test_done

0 commit comments

Comments
 (0)