[PATCH] Replace parse_blob() with an explanatory comment
From: Daniel Barkalow <hidden>
Date: 2016-06-15 22:48:03
Subsystem:
the rest · Maintainer:
Linus Torvalds
parse_blob() has never actually been used; it has served simply to avoid having a confusing gap in the API. Instead of leaving it, put in a comment that explains what "parsing a blob" entails (making sure the object is actually readable), and why code might care whether a blob has been parsed or not. Signed-off-by: Daniel Barkalow <redacted> --- I also realized that the code that used to use the "parsed" bit to distinguish blobs that had actually be read from blobs that had only been referenced (fsck-cache, at the time) no longer works that way, as far as I can tell. However, I think it's worth maintaining the convention that it used, and better not to say that nothing known presently relies on it, since that could change. blob.c | 21 --------------------- blob.h | 9 ++++++++- 2 files changed, 8 insertions(+), 22 deletions(-)
diff --git a/blob.c b/blob.c
index bd7d078..ae320bd 100644
--- a/blob.c
+++ b/blob.c@@ -23,24 +23,3 @@ int parse_blob_buffer(struct blob *item, void *buffer, unsigned long size) item->object.parsed = 1; return 0; } - -int parse_blob(struct blob *item) -{ - enum object_type type; - void *buffer; - unsigned long size; - int ret; - - if (item->object.parsed) - return 0; - buffer = read_sha1_file(item->object.sha1, &type, &size); - if (!buffer) - return error("Could not read %s", - sha1_to_hex(item->object.sha1)); - if (type != OBJ_BLOB) - return error("Object %s not a blob", - sha1_to_hex(item->object.sha1)); - ret = parse_blob_buffer(item, buffer, size); - free(buffer); - return ret; -}
diff --git a/blob.h b/blob.h
index ea5d9e9..38ea395 100644
--- a/blob.h
+++ b/blob.h@@ -13,6 +13,13 @@ struct blob *lookup_blob(const unsigned char *sha1); int parse_blob_buffer(struct blob *item, void *buffer, unsigned long size); -int parse_blob(struct blob *item); +/** + * Blobs do not contain references to other objects and do not have + * structured data that needs parsing. However, code may use the + * "parsed" bit in the struct object for a blob to determine whether + * its content has been found to actually be available, so + * parse_blob_buffer() is used (by object.c) to flag that the object + * has been read successfully from the database. + **/ #endif /* BLOB_H */
--
1.6.6.rc0.354.g373a9.dirty