Convert remaining callers of lookup_blob to object_id
All but a few callers of lookup_blob have been converted to struct object_id. Introduce a temporary, which will be removed later, into parse_object to ease the transition, and convert the remaining callers so that we can update lookup_blob to take struct object_id *. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
834bc47b42
commit
3e9309815d
@ -785,7 +785,7 @@ static int check_collison(struct object_entry *entry)
|
|||||||
|
|
||||||
static void sha1_object(const void *data, struct object_entry *obj_entry,
|
static void sha1_object(const void *data, struct object_entry *obj_entry,
|
||||||
unsigned long size, enum object_type type,
|
unsigned long size, enum object_type type,
|
||||||
const unsigned char *sha1)
|
const struct object_id *oid)
|
||||||
{
|
{
|
||||||
void *new_data = NULL;
|
void *new_data = NULL;
|
||||||
int collision_test_needed = 0;
|
int collision_test_needed = 0;
|
||||||
@ -794,7 +794,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
|
|||||||
|
|
||||||
if (startup_info->have_repository) {
|
if (startup_info->have_repository) {
|
||||||
read_lock();
|
read_lock();
|
||||||
collision_test_needed = has_sha1_file_with_flags(sha1, HAS_SHA1_QUICK);
|
collision_test_needed = has_sha1_file_with_flags(oid->hash, HAS_SHA1_QUICK);
|
||||||
read_unlock();
|
read_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -809,31 +809,31 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
|
|||||||
enum object_type has_type;
|
enum object_type has_type;
|
||||||
unsigned long has_size;
|
unsigned long has_size;
|
||||||
read_lock();
|
read_lock();
|
||||||
has_type = sha1_object_info(sha1, &has_size);
|
has_type = sha1_object_info(oid->hash, &has_size);
|
||||||
if (has_type < 0)
|
if (has_type < 0)
|
||||||
die(_("cannot read existing object info %s"), sha1_to_hex(sha1));
|
die(_("cannot read existing object info %s"), oid_to_hex(oid));
|
||||||
if (has_type != type || has_size != size)
|
if (has_type != type || has_size != size)
|
||||||
die(_("SHA1 COLLISION FOUND WITH %s !"), sha1_to_hex(sha1));
|
die(_("SHA1 COLLISION FOUND WITH %s !"), oid_to_hex(oid));
|
||||||
has_data = read_sha1_file(sha1, &has_type, &has_size);
|
has_data = read_sha1_file(oid->hash, &has_type, &has_size);
|
||||||
read_unlock();
|
read_unlock();
|
||||||
if (!data)
|
if (!data)
|
||||||
data = new_data = get_data_from_pack(obj_entry);
|
data = new_data = get_data_from_pack(obj_entry);
|
||||||
if (!has_data)
|
if (!has_data)
|
||||||
die(_("cannot read existing object %s"), sha1_to_hex(sha1));
|
die(_("cannot read existing object %s"), oid_to_hex(oid));
|
||||||
if (size != has_size || type != has_type ||
|
if (size != has_size || type != has_type ||
|
||||||
memcmp(data, has_data, size) != 0)
|
memcmp(data, has_data, size) != 0)
|
||||||
die(_("SHA1 COLLISION FOUND WITH %s !"), sha1_to_hex(sha1));
|
die(_("SHA1 COLLISION FOUND WITH %s !"), oid_to_hex(oid));
|
||||||
free(has_data);
|
free(has_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strict) {
|
if (strict) {
|
||||||
read_lock();
|
read_lock();
|
||||||
if (type == OBJ_BLOB) {
|
if (type == OBJ_BLOB) {
|
||||||
struct blob *blob = lookup_blob(sha1);
|
struct blob *blob = lookup_blob(oid->hash);
|
||||||
if (blob)
|
if (blob)
|
||||||
blob->object.flags |= FLAG_CHECKED;
|
blob->object.flags |= FLAG_CHECKED;
|
||||||
else
|
else
|
||||||
die(_("invalid blob object %s"), sha1_to_hex(sha1));
|
die(_("invalid blob object %s"), oid_to_hex(oid));
|
||||||
} else {
|
} else {
|
||||||
struct object *obj;
|
struct object *obj;
|
||||||
int eaten;
|
int eaten;
|
||||||
@ -845,7 +845,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
|
|||||||
* we do not need to free the memory here, as the
|
* we do not need to free the memory here, as the
|
||||||
* buf is deleted by the caller.
|
* buf is deleted by the caller.
|
||||||
*/
|
*/
|
||||||
obj = parse_object_buffer(sha1, type, size, buf, &eaten);
|
obj = parse_object_buffer(oid->hash, type, size, buf, &eaten);
|
||||||
if (!obj)
|
if (!obj)
|
||||||
die(_("invalid %s"), typename(type));
|
die(_("invalid %s"), typename(type));
|
||||||
if (do_fsck_object &&
|
if (do_fsck_object &&
|
||||||
@ -960,7 +960,7 @@ static void resolve_delta(struct object_entry *delta_obj,
|
|||||||
typename(delta_obj->real_type),
|
typename(delta_obj->real_type),
|
||||||
delta_obj->idx.oid.hash);
|
delta_obj->idx.oid.hash);
|
||||||
sha1_object(result->data, NULL, result->size, delta_obj->real_type,
|
sha1_object(result->data, NULL, result->size, delta_obj->real_type,
|
||||||
delta_obj->idx.oid.hash);
|
&delta_obj->idx.oid);
|
||||||
counter_lock();
|
counter_lock();
|
||||||
nr_resolved_deltas++;
|
nr_resolved_deltas++;
|
||||||
counter_unlock();
|
counter_unlock();
|
||||||
@ -1149,7 +1149,7 @@ static void parse_pack_objects(unsigned char *sha1)
|
|||||||
nr_delays++;
|
nr_delays++;
|
||||||
} else
|
} else
|
||||||
sha1_object(data, NULL, obj->size, obj->type,
|
sha1_object(data, NULL, obj->size, obj->type,
|
||||||
obj->idx.oid.hash);
|
&obj->idx.oid);
|
||||||
free(data);
|
free(data);
|
||||||
display_progress(progress, i+1);
|
display_progress(progress, i+1);
|
||||||
}
|
}
|
||||||
@ -1176,7 +1176,7 @@ static void parse_pack_objects(unsigned char *sha1)
|
|||||||
continue;
|
continue;
|
||||||
obj->real_type = obj->type;
|
obj->real_type = obj->type;
|
||||||
sha1_object(NULL, obj, obj->size, obj->type,
|
sha1_object(NULL, obj, obj->size, obj->type,
|
||||||
obj->idx.oid.hash);
|
&obj->idx.oid);
|
||||||
nr_delays--;
|
nr_delays--;
|
||||||
}
|
}
|
||||||
if (nr_delays)
|
if (nr_delays)
|
||||||
|
@ -161,14 +161,14 @@ static int both_empty(struct name_entry *a, struct name_entry *b)
|
|||||||
return !(a->oid || b->oid);
|
return !(a->oid || b->oid);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct merge_list *create_entry(unsigned stage, unsigned mode, const unsigned char *sha1, const char *path)
|
static struct merge_list *create_entry(unsigned stage, unsigned mode, const struct object_id *oid, const char *path)
|
||||||
{
|
{
|
||||||
struct merge_list *res = xcalloc(1, sizeof(*res));
|
struct merge_list *res = xcalloc(1, sizeof(*res));
|
||||||
|
|
||||||
res->stage = stage;
|
res->stage = stage;
|
||||||
res->path = path;
|
res->path = path;
|
||||||
res->mode = mode;
|
res->mode = mode;
|
||||||
res->blob = lookup_blob(sha1);
|
res->blob = lookup_blob(oid->hash);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,8 +188,8 @@ static void resolve(const struct traverse_info *info, struct name_entry *ours, s
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
path = traverse_path(info, result);
|
path = traverse_path(info, result);
|
||||||
orig = create_entry(2, ours->mode, ours->oid->hash, path);
|
orig = create_entry(2, ours->mode, ours->oid, path);
|
||||||
final = create_entry(0, result->mode, result->oid->hash, path);
|
final = create_entry(0, result->mode, result->oid, path);
|
||||||
|
|
||||||
final->link = orig;
|
final->link = orig;
|
||||||
|
|
||||||
@ -239,7 +239,7 @@ static struct merge_list *link_entry(unsigned stage, const struct traverse_info
|
|||||||
path = entry->path;
|
path = entry->path;
|
||||||
else
|
else
|
||||||
path = traverse_path(info, n);
|
path = traverse_path(info, n);
|
||||||
link = create_entry(stage, n->mode, n->oid->hash, path);
|
link = create_entry(stage, n->mode, n->oid, path);
|
||||||
link->link = entry;
|
link->link = entry;
|
||||||
return link;
|
return link;
|
||||||
}
|
}
|
||||||
|
9
object.c
9
object.c
@ -190,7 +190,7 @@ struct object *parse_object_buffer(const unsigned char *sha1, enum object_type t
|
|||||||
|
|
||||||
obj = NULL;
|
obj = NULL;
|
||||||
if (type == OBJ_BLOB) {
|
if (type == OBJ_BLOB) {
|
||||||
struct blob *blob = lookup_blob(sha1);
|
struct blob *blob = lookup_blob(oid.hash);
|
||||||
if (blob) {
|
if (blob) {
|
||||||
if (parse_blob_buffer(blob, buffer, size))
|
if (parse_blob_buffer(blob, buffer, size))
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -251,8 +251,11 @@ struct object *parse_object(const unsigned char *sha1)
|
|||||||
const unsigned char *repl = lookup_replace_object(sha1);
|
const unsigned char *repl = lookup_replace_object(sha1);
|
||||||
void *buffer;
|
void *buffer;
|
||||||
struct object *obj;
|
struct object *obj;
|
||||||
|
struct object_id oid;
|
||||||
|
|
||||||
obj = lookup_object(sha1);
|
hashcpy(oid.hash, sha1);
|
||||||
|
|
||||||
|
obj = lookup_object(oid.hash);
|
||||||
if (obj && obj->parsed)
|
if (obj && obj->parsed)
|
||||||
return obj;
|
return obj;
|
||||||
|
|
||||||
@ -263,7 +266,7 @@ struct object *parse_object(const unsigned char *sha1)
|
|||||||
error("sha1 mismatch %s", sha1_to_hex(repl));
|
error("sha1 mismatch %s", sha1_to_hex(repl));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
parse_blob_buffer(lookup_blob(sha1), NULL, 0);
|
parse_blob_buffer(lookup_blob(oid.hash), NULL, 0);
|
||||||
return lookup_object(sha1);
|
return lookup_object(sha1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user