2023-02-24 03:09:30 +03:00
|
|
|
#include "git-compat-util.h"
|
2006-01-07 12:33:54 +03:00
|
|
|
#include "blob.h"
|
2018-05-08 22:37:25 +03:00
|
|
|
#include "repository.h"
|
2018-05-16 00:48:42 +03:00
|
|
|
#include "alloc.h"
|
2005-04-18 22:39:48 +04:00
|
|
|
|
|
|
|
const char *blob_type = "blob";
|
|
|
|
|
2018-06-29 04:22:08 +03:00
|
|
|
struct blob *lookup_blob(struct repository *r, const struct object_id *oid)
|
2005-04-18 22:39:48 +04:00
|
|
|
{
|
2019-06-20 10:41:14 +03:00
|
|
|
struct object *obj = lookup_object(r, oid);
|
2007-04-17 09:11:43 +04:00
|
|
|
if (!obj)
|
2019-06-20 10:41:21 +03:00
|
|
|
return create_object(r, oid, alloc_blob_node(r));
|
2020-06-17 12:14:08 +03:00
|
|
|
return object_as_type(obj, OBJ_BLOB, 0);
|
2005-04-18 22:39:48 +04:00
|
|
|
}
|
2005-04-28 18:46:33 +04:00
|
|
|
|
blob: drop unused parts of parse_blob_buffer()
Our parse_blob_buffer() takes a ptr/len combo, just like
parse_tree_buffer(), etc, and returns success or failure. But it doesn't
actually do anything with them; we just set the "parsed" flag in the
object and return success, without even looking at the contents.
There could be some value to keeping these unused parameters:
- it's consistent with the parse functions for other object types. But
we already lost that consistency in 837d395a5c (Replace parse_blob()
with an explanatory comment, 2010-01-18).
- As the comment from 837d395a5c explains, callers are supposed to
make sure they have the object content available. So in theory
asking for these parameters could serve as a signal. But there are
only two callers, and one of them always passes NULL (after doing a
streaming check of the object hash).
This shows that there aren't likely to be a lot of callers (since
everyone either uses the type-generic parse functions, or handles
blobs individually), and that they need to take special care anyway
(because we usually want to avoid loading whole blobs in memory if
we can avoid it).
So let's just drop these unused parameters, and likewise the useless
return value. While we're touching the header file, let's move the
declaration of parse_blob_buffer() right below that explanatory comment,
where it's more likely to be seen by people looking for the function.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-12-13 14:11:57 +03:00
|
|
|
void parse_blob_buffer(struct blob *item)
|
2005-05-06 21:48:34 +04:00
|
|
|
{
|
|
|
|
item->object.parsed = 1;
|
|
|
|
}
|