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:
brian m. carlson 2017-05-06 22:10:13 +00:00 коммит произвёл Junio C Hamano
Родитель 834bc47b42
Коммит 3e9309815d
3 изменённых файлов: 25 добавлений и 22 удалений

Просмотреть файл

@ -785,7 +785,7 @@ static int check_collison(struct object_entry *entry)
static void sha1_object(const void *data, struct object_entry *obj_entry,
unsigned long size, enum object_type type,
const unsigned char *sha1)
const struct object_id *oid)
{
void *new_data = NULL;
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) {
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();
}
@ -809,31 +809,31 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
enum object_type has_type;
unsigned long has_size;
read_lock();
has_type = sha1_object_info(sha1, &has_size);
has_type = sha1_object_info(oid->hash, &has_size);
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)
die(_("SHA1 COLLISION FOUND WITH %s !"), sha1_to_hex(sha1));
has_data = read_sha1_file(sha1, &has_type, &has_size);
die(_("SHA1 COLLISION FOUND WITH %s !"), oid_to_hex(oid));
has_data = read_sha1_file(oid->hash, &has_type, &has_size);
read_unlock();
if (!data)
data = new_data = get_data_from_pack(obj_entry);
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 ||
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);
}
if (strict) {
read_lock();
if (type == OBJ_BLOB) {
struct blob *blob = lookup_blob(sha1);
struct blob *blob = lookup_blob(oid->hash);
if (blob)
blob->object.flags |= FLAG_CHECKED;
else
die(_("invalid blob object %s"), sha1_to_hex(sha1));
die(_("invalid blob object %s"), oid_to_hex(oid));
} else {
struct object *obj;
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
* 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)
die(_("invalid %s"), typename(type));
if (do_fsck_object &&
@ -960,7 +960,7 @@ static void resolve_delta(struct object_entry *delta_obj,
typename(delta_obj->real_type),
delta_obj->idx.oid.hash);
sha1_object(result->data, NULL, result->size, delta_obj->real_type,
delta_obj->idx.oid.hash);
&delta_obj->idx.oid);
counter_lock();
nr_resolved_deltas++;
counter_unlock();
@ -1149,7 +1149,7 @@ static void parse_pack_objects(unsigned char *sha1)
nr_delays++;
} else
sha1_object(data, NULL, obj->size, obj->type,
obj->idx.oid.hash);
&obj->idx.oid);
free(data);
display_progress(progress, i+1);
}
@ -1176,7 +1176,7 @@ static void parse_pack_objects(unsigned char *sha1)
continue;
obj->real_type = obj->type;
sha1_object(NULL, obj, obj->size, obj->type,
obj->idx.oid.hash);
&obj->idx.oid);
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);
}
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));
res->stage = stage;
res->path = path;
res->mode = mode;
res->blob = lookup_blob(sha1);
res->blob = lookup_blob(oid->hash);
return res;
}
@ -188,8 +188,8 @@ static void resolve(const struct traverse_info *info, struct name_entry *ours, s
return;
path = traverse_path(info, result);
orig = create_entry(2, ours->mode, ours->oid->hash, path);
final = create_entry(0, result->mode, result->oid->hash, path);
orig = create_entry(2, ours->mode, ours->oid, path);
final = create_entry(0, result->mode, result->oid, path);
final->link = orig;
@ -239,7 +239,7 @@ static struct merge_list *link_entry(unsigned stage, const struct traverse_info
path = entry->path;
else
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;
return link;
}

Просмотреть файл

@ -190,7 +190,7 @@ struct object *parse_object_buffer(const unsigned char *sha1, enum object_type t
obj = NULL;
if (type == OBJ_BLOB) {
struct blob *blob = lookup_blob(sha1);
struct blob *blob = lookup_blob(oid.hash);
if (blob) {
if (parse_blob_buffer(blob, buffer, size))
return NULL;
@ -251,8 +251,11 @@ struct object *parse_object(const unsigned char *sha1)
const unsigned char *repl = lookup_replace_object(sha1);
void *buffer;
struct object *obj;
struct object_id oid;
obj = lookup_object(sha1);
hashcpy(oid.hash, sha1);
obj = lookup_object(oid.hash);
if (obj && obj->parsed)
return obj;
@ -263,7 +266,7 @@ struct object *parse_object(const unsigned char *sha1)
error("sha1 mismatch %s", sha1_to_hex(repl));
return NULL;
}
parse_blob_buffer(lookup_blob(sha1), NULL, 0);
parse_blob_buffer(lookup_blob(oid.hash), NULL, 0);
return lookup_object(sha1);
}