aboutsummaryrefslogtreecommitdiffstats
path: root/fsck.c
diff options
context:
space:
mode:
authorRamsay Jones <ramsay@ramsayjones.plus.com>2018-06-27 19:39:53 +0100
committerJunio C Hamano <gitster@pobox.com>2018-07-03 09:49:44 -0700
commitfb16287719375b86818aca0d2df2496b925e9380 (patch)
tree2db05b30e8d99ee029ff3a63ac85fd2432779b2b /fsck.c
parent47cc91310a81ca606e6bebcccf168bc1cb297d8e (diff)
downloadgit-fb16287719375b86818aca0d2df2496b925e9380.tar.gz
fsck: check skiplist for object in fsck_blob()
Since commit ed8b10f631 ("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 <ramsay@ramsayjones.plus.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'fsck.c')
-rw-r--r--fsck.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/fsck.c b/fsck.c
index 35af51553d..e91cbf6d44 100644
--- a/fsck.c
+++ b/fsck.c
@@ -281,6 +281,13 @@ static void append_msg_id(struct strbuf *sb, const char *msg_id)
strbuf_addstr(sb, ": ");
}
+static int object_on_skiplist(struct fsck_options *opts, struct object *obj)
+{
+ if (opts && opts->skiplist && obj)
+ return oid_array_lookup(opts->skiplist, &obj->oid) >= 0;
+ return 0;
+}
+
__attribute__((format (printf, 4, 5)))
static int report(struct fsck_options *options, struct object *object,
enum fsck_msg_id id, const char *fmt, ...)
@@ -292,8 +299,7 @@ static int report(struct fsck_options *options, struct object *object,
if (msg_type == FSCK_IGNORE)
return 0;
- if (options->skiplist && object &&
- oid_array_lookup(options->skiplist, &object->oid) >= 0)
+ if (object_on_skiplist(options, object))
return 0;
if (msg_type == FSCK_FATAL)
@@ -959,6 +965,9 @@ static int fsck_blob(struct blob *blob, const char *buf,
return 0;
oidset_insert(&gitmodules_done, &blob->object.oid);
+ if (object_on_skiplist(options, &blob->object))
+ return 0;
+
if (!buf) {
/*
* A missing buffer here is a sign that the caller found the