File tree Expand file tree Collapse file tree 2 files changed +24
-8
lines changed Expand file tree Collapse file tree 2 files changed +24
-8
lines changed Original file line number Diff line number Diff line change @@ -1036,7 +1036,8 @@ int fsck_finish(struct fsck_options *options)
1036
1036
1037
1037
blob = lookup_blob (oid );
1038
1038
if (!blob ) {
1039
- ret |= report (options , & blob -> object ,
1039
+ struct object * obj = lookup_unknown_object (oid -> hash );
1040
+ ret |= report (options , obj ,
1040
1041
FSCK_MSG_GITMODULES_BLOB ,
1041
1042
"non-blob found at .gitmodules" );
1042
1043
continue ;
Original file line number Diff line number Diff line change @@ -135,13 +135,10 @@ test_expect_success 'fsck detects symlinked .gitmodules file' '
135
135
tricky="[foo]bar=true" &&
136
136
content=$(git hash-object -w ../.gitmodules) &&
137
137
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 &&
145
142
146
143
# Check not only that we fail, but that it is due to the
147
144
# symlink detector; this grep string comes from the config
@@ -151,4 +148,22 @@ test_expect_success 'fsck detects symlinked .gitmodules file' '
151
148
)
152
149
'
153
150
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
+
154
169
test_done
You can’t perform that action at this time.
0 commit comments