Skip to content

Commit 542d6ab

Browse files
peffgitster
authored andcommitted
object.h: expand docstring for lookup_unknown_object()
The lookup_unknown_object() system is not often used and is somewhat confusing. Let's try to explain it a bit more (which is especially important as I'm adding a related but slightly different function in the next commit). Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b2086b5 commit 542d6ab

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

object.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,18 @@ struct object *parse_object_or_die(const struct object_id *oid, const char *name
144144
*/
145145
struct object *parse_object_buffer(struct repository *r, const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p);
146146

147-
/** Returns the object, with potentially excess memory allocated. **/
147+
/*
148+
* Allocate and return an object struct, even if you do not know the type of
149+
* the object. The returned object may have its "type" field set to a real type
150+
* (if somebody previously called lookup_blob(), etc), or it may be set to
151+
* OBJ_NONE. In the latter case, subsequent calls to lookup_blob(), etc, will
152+
* set the type field as appropriate.
153+
*
154+
* Use this when you do not know the expected type of an object and want to
155+
* avoid parsing it for efficiency reasons. Try to avoid it otherwise; it
156+
* may allocate excess memory, since the returned object must be as large as
157+
* the maximum struct of any type.
158+
*/
148159
struct object *lookup_unknown_object(struct repository *r, const struct object_id *oid);
149160

150161
struct object_list *object_list_insert(struct object *item,

0 commit comments

Comments
 (0)