mirror of
https://github.com/git/git.git
synced 2025-12-12 20:36:24 +01:00
odb: rename read_object_with_reference()
Rename `read_object_with_reference()` to `odb_read_object_peeled()` to match other functions related to the object database and our modern coding guidelines. Furthermore though, the old name didn't really describe very well what this function actually does, which is to walk down any commit and tag objects until an object of the required type has been found. This is generally referred to as "peeling", so the new name should be way more descriptive. No compatibility wrapper is introduced as the function is not used a lot throughout our codebase. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
08218b8cd4
commit
841a03b404
17
odb.c
17
odb.c
@@ -905,11 +905,11 @@ void *odb_read_object(struct object_database *odb,
|
||||
return data;
|
||||
}
|
||||
|
||||
void *read_object_with_reference(struct repository *r,
|
||||
const struct object_id *oid,
|
||||
enum object_type required_type,
|
||||
unsigned long *size,
|
||||
struct object_id *actual_oid_return)
|
||||
void *odb_read_object_peeled(struct object_database *odb,
|
||||
const struct object_id *oid,
|
||||
enum object_type required_type,
|
||||
unsigned long *size,
|
||||
struct object_id *actual_oid_return)
|
||||
{
|
||||
enum object_type type;
|
||||
void *buffer;
|
||||
@@ -921,7 +921,7 @@ void *read_object_with_reference(struct repository *r,
|
||||
int ref_length = -1;
|
||||
const char *ref_type = NULL;
|
||||
|
||||
buffer = odb_read_object(r->objects, &actual_oid, &type, &isize);
|
||||
buffer = odb_read_object(odb, &actual_oid, &type, &isize);
|
||||
if (!buffer)
|
||||
return NULL;
|
||||
if (type == required_type) {
|
||||
@@ -941,9 +941,10 @@ void *read_object_with_reference(struct repository *r,
|
||||
}
|
||||
ref_length = strlen(ref_type);
|
||||
|
||||
if (ref_length + r->hash_algo->hexsz > isize ||
|
||||
if (ref_length + odb->repo->hash_algo->hexsz > isize ||
|
||||
memcmp(buffer, ref_type, ref_length) ||
|
||||
get_oid_hex_algop((char *) buffer + ref_length, &actual_oid, r->hash_algo)) {
|
||||
get_oid_hex_algop((char *) buffer + ref_length, &actual_oid,
|
||||
odb->repo->hash_algo)) {
|
||||
free(buffer);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user