Skip to content

Commit fb16287

Browse files
ramsay-jonesgitster
authored andcommitted
fsck: check skiplist for object in fsck_blob()
Since commit ed8b10f ("fsck: check .gitmodules content", 2018-05-02), fsck will issue an error message for '.gitmodules' content that cannot be parsed correctly. This is the case, even when the corresponding blob object has been included on the skiplist. For example, using the cgit repository, we see the following: $ git fsck Checking object directories: 100% (256/256), done. error: bad config line 5 in blob .gitmodules error in blob 51dd1eff1edc663674df9ab85d2786a40f7ae3a5: gitmodulesParse: could not parse gitmodules blob Checking objects: 100% (6626/6626), done. $ $ git config fsck.skiplist '.git/skip' $ echo 51dd1eff1edc663674df9ab85d2786a40f7ae3a5 >.git/skip $ $ git fsck Checking object directories: 100% (256/256), done. error: bad config line 5 in blob .gitmodules Checking objects: 100% (6626/6626), done. $ Note that the error message issued by the config parser is still present, despite adding the object-id of the blob to the skiplist. One solution would be to provide a means of suppressing the messages issued by the config parser. However, given that (logically) we are asking fsck to ignore this object, a simpler approach is to just not call the config parser if the object is to be skipped. Add a check to the 'fsck_blob()' processing function, to determine if the object is on the skiplist and, if so, exit the function early. Signed-off-by: Ramsay Jones <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 47cc913 commit fb16287

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

fsck.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,13 @@ static void append_msg_id(struct strbuf *sb, const char *msg_id)
281281
strbuf_addstr(sb, ": ");
282282
}
283283

284+
static int object_on_skiplist(struct fsck_options *opts, struct object *obj)
285+
{
286+
if (opts && opts->skiplist && obj)
287+
return oid_array_lookup(opts->skiplist, &obj->oid) >= 0;
288+
return 0;
289+
}
290+
284291
__attribute__((format (printf, 4, 5)))
285292
static int report(struct fsck_options *options, struct object *object,
286293
enum fsck_msg_id id, const char *fmt, ...)
@@ -292,8 +299,7 @@ static int report(struct fsck_options *options, struct object *object,
292299
if (msg_type == FSCK_IGNORE)
293300
return 0;
294301

295-
if (options->skiplist && object &&
296-
oid_array_lookup(options->skiplist, &object->oid) >= 0)
302+
if (object_on_skiplist(options, object))
297303
return 0;
298304

299305
if (msg_type == FSCK_FATAL)
@@ -959,6 +965,9 @@ static int fsck_blob(struct blob *blob, const char *buf,
959965
return 0;
960966
oidset_insert(&gitmodules_done, &blob->object.oid);
961967

968+
if (object_on_skiplist(options, &blob->object))
969+
return 0;
970+
962971
if (!buf) {
963972
/*
964973
* A missing buffer here is a sign that the caller found the

0 commit comments

Comments
 (0)