summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fsck.c3
-rwxr-xr-xt/t7415-submodule-names.sh18
2 files changed, 20 insertions, 1 deletions
diff --git a/fsck.c b/fsck.c
index 9339f31513..35af51553d 100644
--- a/fsck.c
+++ b/fsck.c
@@ -1032,7 +1032,8 @@ int fsck_finish(struct fsck_options *options)
blob = lookup_blob(oid);
if (!blob) {
- ret |= report(options, &blob->object,
+ struct object *obj = lookup_unknown_object(oid->hash);
+ ret |= report(options, obj,
FSCK_MSG_GITMODULES_BLOB,
"non-blob found at .gitmodules");
continue;
diff --git a/t/t7415-submodule-names.sh b/t/t7415-submodule-names.sh
index 541bd81684..3c0f1a102a 100755
--- a/t/t7415-submodule-names.sh
+++ b/t/t7415-submodule-names.sh
@@ -148,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