Thread (103 messages) flat view 103 messages, 6 authors, 2021-04-22

Re: [PATCH v2 2/8] object.c: add a utility function for "expected type X, got Y"

From: Jonathan Tan <hidden>
Date: 2021-04-21 22:04:33

quoted hunk ↗ jump to hunk
diff --git a/merge-recursive.c b/merge-recursive.c
index 7618303f7b..b952106203 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -2999,6 +2999,7 @@ static int read_oid_strbuf(struct merge_options *opt,
 	if (!buf)
 		return err(opt, _("cannot read object %s"), oid_to_hex(oid));
 	if (type != OBJ_BLOB) {
+		const char* msg = oid_is_type_or_die_msg(oid, OBJ_BLOB, &type);
 		free(buf);
 		return err(opt, _("object %s is not a blob"), oid_to_hex(oid));
 	}
Stray extra line.
+void oid_is_type_or_die(const struct object_id *oid,
+			enum object_type want,
+			enum object_type *type)
+{
Thanks - this looks like a good simplification.

Why is type a pointer? Maybe it's to better distinguish the values at
the call site (one pointer, one not), but this solution is confusing
too.
+int oid_is_type_or_error(const struct object_id *oid,
+			 enum object_type want,
+			 enum object_type *type)
+{
Same comment.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help