{"thread":{"id":"22270","subject":"[PATCH] Replace parse_blob() with an explanatory comment","startedAt":"2010-01-18T18:06:28Z","lastAt":"2010-01-18T18:06:28Z","messageCount":1,"participants":["Daniel Barkalow"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"132041","messageId":"alpine.LNX.2.00.1001181301070.14365@iabervon.org","threadId":"22270","inReplyTo":null,"subject":"[PATCH] Replace parse_blob() with an explanatory comment","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2010-01-18T18:06:28Z","receivedAt":"2010-01-18T18:06:28Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"parse_blob() has never actually been used; it has served simply to\navoid having a confusing gap in the API. Instead of leaving it, put in\na comment that explains what \"parsing a blob\" entails (making sure the\nobject is actually readable), and why code might care whether a blob\nhas been parsed or not.\n\nSigned-off-by: Daniel Barkalow <barkalow@iabervon.org>\n---\nI also realized that the code that used to use the \"parsed\" bit to \ndistinguish blobs that had actually be read from blobs that had only been \nreferenced (fsck-cache, at the time) no longer works that way, as far as I \ncan tell. However, I think it's worth maintaining the convention that it \nused, and better not to say that nothing known presently relies on it, \nsince that could change.\n\n blob.c |   21 ---------------------\n blob.h |    9 ++++++++-\n 2 files changed, 8 insertions(+), 22 deletions(-)\n\ndiff --git a/blob.c b/blob.c\nindex bd7d078..ae320bd 100644\n--- a/blob.c\n+++ b/blob.c\n@@ -23,24 +23,3 @@ int parse_blob_buffer(struct blob *item, void *buffer, unsigned long size)\n \titem->object.parsed = 1;\n \treturn 0;\n }\n-\n-int parse_blob(struct blob *item)\n-{\n-        enum object_type type;\n-        void *buffer;\n-        unsigned long size;\n-\tint ret;\n-\n-        if (item->object.parsed)\n-                return 0;\n-        buffer = read_sha1_file(item->object.sha1, &type, &size);\n-        if (!buffer)\n-                return error(\"Could not read %s\",\n-                             sha1_to_hex(item->object.sha1));\n-        if (type != OBJ_BLOB)\n-                return error(\"Object %s not a blob\",\n-                             sha1_to_hex(item->object.sha1));\n-\tret = parse_blob_buffer(item, buffer, size);\n-\tfree(buffer);\n-\treturn ret;\n-}\ndiff --git a/blob.h b/blob.h\nindex ea5d9e9..38ea395 100644\n--- a/blob.h\n+++ b/blob.h\n@@ -13,6 +13,13 @@ struct blob *lookup_blob(const unsigned char *sha1);\n \n int parse_blob_buffer(struct blob *item, void *buffer, unsigned long size);\n \n-int parse_blob(struct blob *item);\n+/** \n+ * Blobs do not contain references to other objects and do not have\n+ * structured data that needs parsing. However, code may use the\n+ * \"parsed\" bit in the struct object for a blob to determine whether\n+ * its content has been found to actually be available, so\n+ * parse_blob_buffer() is used (by object.c) to flag that the object\n+ * has been read successfully from the database.\n+ **/\n \n #endif /* BLOB_H */\n-- \n1.6.6.rc0.354.g373a9.dirty\n"}]}