Re: [PATCH v2 06/10] blob.c: remove parse_blob_buffer()
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Apr 29, 2021, 04:51 UTC
- Message-ID
- <xmqq5z058zht.fsf@gitster.g>
- In-Reply-To
- <patch-06.10-02c8d2a9ba-20210420T124428Z-avarab@gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
Show 5 quoted lines
> -int parse_blob_buffer(struct blob *item, void *buffer, unsigned long size)
> -{
> - item->object.parsed = 1;
> - return 0;
> -}Understandable.
Show 13 quoted lines
> diff --git a/object.c b/object.c
> index 78343781ae..f4e419e5c3 100644
> --- a/object.c
> +++ b/object.c
> @@ -195,8 +195,7 @@ struct object *parse_object_buffer(struct repository *r, const struct object_id
> if (type == OBJ_BLOB) {
> struct blob *blob = lookup_blob(r, oid);
> if (blob) {
> - if (parse_blob_buffer(blob, buffer, size))
> - return NULL;
> + blob->object.parsed = 1;
> obj = &blob->object;
> }Understandable, too.
Show 9 quoted lines
> } else if (type == OBJ_TREE) {
> @@ -262,12 +261,16 @@ struct object *parse_object(struct repository *r, const struct object_id *oid)
> if ((obj && obj->type == OBJ_BLOB && repo_has_object_file(r, oid)) ||
> (!obj && repo_has_object_file(r, oid) &&
> oid_object_info(r, oid, NULL) == OBJ_BLOB)) {
> + if (!obj) {
> + struct blob *blob = create_blob(r, oid);
> + obj = &blob->object;
> + }I do not recall this change explained or justified in the log message. What am I missing?
Show 8 quoted lines
> if (check_object_signature(r, repl, NULL, 0, NULL) < 0) {
> error(_("hash mismatch %s"), oid_to_hex(oid));
> return NULL;
> }
> - parse_blob_buffer(lookup_blob(r, oid), NULL, 0);
> - return lookup_object(r, oid);
> + obj->parsed = 1;
> + return obj;Likewise. Why isn't it just a call to lookup_blob() followed by setting of its .parsed bit?
In other words, it is not clear why we need to expose create_blob().
> } > > buffer = repo_read_object_file(r, oid, &type, &size);