All of lore.kernel.org
 help / color / mirror / Atom feed
From: Olga Telezhnaya <olyatelezhnaya@gmail.com>
To: git@vger.kernel.org
Subject: [PATCH v2 3/4] ref-filter: merge get_obj and get_object
Date: Fri, 13 Jul 2018 12:43:56 +0000	[thread overview]
Message-ID: <0102016493ab5420-51c1c19d-e1ca-43cb-8f9e-36f242f5c972-000000@eu-west-1.amazonses.com> (raw)
In-Reply-To: <0102016493ab5347-c0429041-6e66-4550-894c-2d500cb2ed8e-000000@eu-west-1.amazonses.com>

Inline get_obj(): it would be easier to edit the code
without this split.

Signed-off-by: Olga Telezhnaia <olyatelezhnaya@gmail.com>
---
 ref-filter.c | 36 +++++++++++-------------------------
 1 file changed, 11 insertions(+), 25 deletions(-)

diff --git a/ref-filter.c b/ref-filter.c
index 27733ef013bed..f04169f0ea0e3 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -797,24 +797,6 @@ int verify_ref_format(struct ref_format *format)
 	return 0;
 }
 
-/*
- * Given an object name, read the object data and size, and return a
- * "struct object".  If the object data we are returning is also borrowed
- * by the "struct object" representation, set *eaten as well---it is a
- * signal from parse_object_buffer to us not to free the buffer.
- */
-static void *get_obj(const struct object_id *oid, struct object **obj, unsigned long *sz, int *eaten)
-{
-	enum object_type type;
-	void *buf = read_object_file(oid, &type, sz);
-
-	if (buf)
-		*obj = parse_object_buffer(oid, type, *sz, buf, eaten);
-	else
-		*obj = NULL;
-	return buf;
-}
-
 static int grab_objectname(const char *name, const struct object_id *oid,
 			   struct atom_value *v, struct used_atom *atom)
 {
@@ -1437,20 +1419,24 @@ static const char *get_refname(struct used_atom *atom, struct ref_array_item *re
 }
 
 static int get_object(struct ref_array_item *ref, const struct object_id *oid,
-		       int deref, struct object **obj, struct strbuf *err)
+		      int deref, struct object **obj, struct strbuf *err)
 {
 	int eaten;
 	int ret = 0;
 	unsigned long size;
-	void *buf = get_obj(oid, obj, &size, &eaten);
+	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 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);
+	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);
+	}
 	if (!eaten)
 		free(buf);
 	return ret;

--
https://github.com/git/git/pull/520

  reply	other threads:[~2018-07-13 12:44 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 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 4/4] ref-filter: use oid_object_info() to get object Olga Telezhnaya
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   ` Olga Telezhnaya [this message]
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
2018-07-17  7:44       ` Оля Тележная
2018-07-17 22:17         ` Junio C Hamano
2018-07-13 12:43   ` [PATCH v2 2/4] ref-filter: fill empty fields with empty values Olga Telezhnaya
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 3/5] ref-filter: initialize eaten variable 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 5/5] ref-filter: use oid_object_info() to get object Olga Telezhnaya
2018-07-17  8:22     ` [PATCH v3 4/5] ref-filter: merge get_obj and get_object 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=0102016493ab5420-51c1c19d-e1ca-43cb-8f9e-36f242f5c972-000000@eu-west-1.amazonses.com \
    --to=olyatelezhnaya@gmail.com \
    --cc=git@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.