From: Junio C Hamano <gitster@pobox.com>
To: Olga Telezhnaya <olyatelezhnaya@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v2 4/4] ref-filter: use oid_object_info() to get object
Date: Mon, 16 Jul 2018 13:53:49 -0700 [thread overview]
Message-ID: <xmqqr2k2sy02.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <0102016493ab542d-ea2a3e8c-d6a0-44ca-8fc6-f940fe7e84cd-000000@eu-west-1.amazonses.com> (Olga Telezhnaya's message of "Fri, 13 Jul 2018 12:43:56 +0000")
Olga Telezhnaya <olyatelezhnaya@gmail.com> writes:
> -static int get_object(struct ref_array_item *ref, const struct object_id *oid,
> - int deref, struct object **obj, struct strbuf *err)
> +static int get_object(struct ref_array_item *ref, int deref, struct object **obj,
> + struct expand_data *oi, struct strbuf *err)
> {
> - int eaten;
> - int ret = 0;
> - unsigned long size;
> - enum object_type type;
> - void *buf = read_object_file(oid, &type, &size);
> - if (!buf)
> - ret = strbuf_addf_ret(err, -1, _("missing object %s for %s"),
> - oid_to_hex(oid), ref->refname);
> - else {
> - *obj = parse_object_buffer(oid, type, size, buf, &eaten);
> - if (!*obj)
> - ret = strbuf_addf_ret(err, -1, _("parse_object_buffer failed on %s for %s"),
> - oid_to_hex(oid), ref->refname);
> - else
> - grab_values(ref->value, deref, *obj, buf, size);
> + /* parse_object_buffer() will set eaten to 0 if free() will be needed */
> + int eaten = 1;
Hmph, doesn't this belong to the previous step? In other words,
isn't the result of applying 1-3/4 has a bug that can leave eaten
uninitialized (and base decision to free(buf) later on it), and
isn't this change a fix for it?
> + if (oi->info.contentp) {
> + /* We need to know that to use parse_object_buffer properly */
> + oi->info.sizep = &oi->size;
> + oi->info.typep = &oi->type;
> }
> + if (oid_object_info_extended(the_repository, &oi->oid, &oi->info,
> + OBJECT_INFO_LOOKUP_REPLACE))
> + return strbuf_addf_ret(err, -1, _("missing object %s for %s"),
> + oid_to_hex(&oi->oid), ref->refname);
> +
> + if (oi->info.contentp) {
> + *obj = parse_object_buffer(&oi->oid, oi->type, oi->size, oi->content, &eaten);
> + if (!obj) {
> + if (!eaten)
> + free(oi->content);
> + return strbuf_addf_ret(err, -1, _("parse_object_buffer failed on %s for %s"),
> + oid_to_hex(&oi->oid), ref->refname);
> + }
> + grab_values(ref->value, deref, *obj, oi->content, oi->size);
> + }
> +
> + grab_common_values(ref->value, deref, oi);
> if (!eaten)
> - free(buf);
> - return ret;
> + free(oi->content);
> + return 0;
> }
next prev parent reply other threads:[~2018-07-16 20:53 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-09 8:12 [PATCH 1/4] ref-filter: add info_source to valid_atom Olga Telezhnaya
2018-07-09 8:12 ` [PATCH 4/4] ref-filter: use oid_object_info() to get object Olga Telezhnaya
2018-07-09 8:12 ` [PATCH 2/4] ref-filter: add empty values to technical fields Olga Telezhnaya
2018-07-09 22:39 ` Junio C Hamano
2018-07-10 7:51 ` Оля Тележная
2018-07-09 8:12 ` [PATCH 3/4] ref-filter: merge get_obj and get_object Olga Telezhnaya
2018-07-10 9:19 ` SZEDER Gábor
2018-07-10 9:23 ` Johannes Schindelin
2018-07-10 10:29 ` SZEDER Gábor
2018-07-10 10:41 ` Оля Тележная
2018-07-13 12:43 ` [PATCH v2 1/4] ref-filter: add info_source to valid_atom Olga Telezhnaya
2018-07-13 12:43 ` [PATCH v2 2/4] ref-filter: fill empty fields with empty values Olga Telezhnaya
2018-07-13 12:43 ` [PATCH v2 3/4] ref-filter: merge get_obj and get_object Olga Telezhnaya
2018-07-13 12:43 ` [PATCH v2 4/4] ref-filter: use oid_object_info() to get object Olga Telezhnaya
2018-07-16 20:53 ` Junio C Hamano [this message]
2018-07-17 7:44 ` Оля Тележная
2018-07-17 22:17 ` Junio C Hamano
2018-07-17 8:22 ` [PATCH v3 1/5] ref-filter: add info_source to valid_atom Olga Telezhnaya
2018-07-17 8:22 ` [PATCH v3 2/5] ref-filter: fill empty fields with empty values Olga Telezhnaya
2018-07-17 8:22 ` [PATCH v3 4/5] ref-filter: merge get_obj and get_object Olga Telezhnaya
2018-07-17 8:22 ` [PATCH v3 5/5] ref-filter: use oid_object_info() to get object Olga Telezhnaya
2018-07-17 8:22 ` [PATCH v3 3/5] ref-filter: initialize eaten variable Olga Telezhnaya
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqr2k2sy02.fsf@gitster-ct.c.googlers.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=olyatelezhnaya@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).