Convert lookup_blob to take a pointer to struct object_id.
The commit was created with manual changes to blob.c and blob.h, plus
the following semantic patch:
@@
expression E1;
@@
- lookup_blob(E1.hash)
+ lookup_blob(&E1)
@@
expression E1;
@@
- lookup_blob(E1->hash)
+ lookup_blob(E1)
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
const char *blob_type = "blob";
-struct blob *lookup_blob(const unsigned char *sha1)
+struct blob *lookup_blob(const struct object_id *oid)
{
- struct object *obj = lookup_object(sha1);
+ struct object *obj = lookup_object(oid->hash);
if (!obj)
- return create_object(sha1, alloc_blob_node());
+ return create_object(oid->hash, alloc_blob_node());
return object_as_type(obj, OBJ_BLOB, 0);
}
struct object object;
};
-struct blob *lookup_blob(const unsigned char *sha1);
+struct blob *lookup_blob(const struct object_id *oid);
int parse_blob_buffer(struct blob *item, void *buffer, unsigned long size);
if (anonymize) {
buf = anonymize_blob(&size);
- object = (struct object *)lookup_blob(oid->hash);
+ object = (struct object *)lookup_blob(oid);
eaten = 0;
} else {
buf = read_sha1_file(oid->hash, &type, &size);
mode = active_cache[i]->ce_mode;
if (S_ISGITLINK(mode))
continue;
- blob = lookup_blob(active_cache[i]->oid.hash);
+ blob = lookup_blob(&active_cache[i]->oid);
if (!blob)
continue;
obj = &blob->object;
if (strict) {
read_lock();
if (type == OBJ_BLOB) {
- struct blob *blob = lookup_blob(oid->hash);
+ struct blob *blob = lookup_blob(oid);
if (blob)
blob->object.flags |= FLAG_CHECKED;
else
res->stage = stage;
res->path = path;
res->mode = mode;
- res->blob = lookup_blob(oid->hash);
+ res->blob = lookup_blob(oid);
return res;
}
added_object(nr, type, buf, size);
free(buf);
- blob = lookup_blob(obj_list[nr].oid.hash);
+ blob = lookup_blob(&obj_list[nr].oid);
if (blob)
blob->object.flags |= FLAG_WRITTEN;
else
result = options->walk(obj, OBJ_TREE, data, options);
}
else if (S_ISREG(entry.mode) || S_ISLNK(entry.mode)) {
- obj = &lookup_blob(entry.oid->hash)->object;
+ obj = &lookup_blob(entry.oid)->object;
if (name)
put_object_name(options, obj, "%s%s", name,
entry.path);
p = process_tree(lookup_tree(entry.oid->hash), p);
break;
case OBJ_BLOB:
- p = process_blob(lookup_blob(entry.oid->hash), p);
+ p = process_blob(lookup_blob(entry.oid), p);
break;
default:
/* Subproject commit - not in this repository */
cb_data);
else
process_blob(revs,
- lookup_blob(entry.oid->hash),
+ lookup_blob(entry.oid),
show, base, entry.path,
cb_data);
}
obj = NULL;
if (type == OBJ_BLOB) {
- struct blob *blob = lookup_blob(oid.hash);
+ struct blob *blob = lookup_blob(&oid);
if (blob) {
if (parse_blob_buffer(blob, buffer, size))
return NULL;
error("sha1 mismatch %s", sha1_to_hex(repl));
return NULL;
}
- parse_blob_buffer(lookup_blob(oid.hash), NULL, 0);
+ parse_blob_buffer(lookup_blob(&oid), NULL, 0);
return lookup_object(sha1);
}
obj = (struct object *)lookup_tree(oid->hash);
break;
case OBJ_BLOB:
- obj = (struct object *)lookup_blob(oid->hash);
+ obj = (struct object *)lookup_blob(oid);
break;
default:
die("unknown object type for %s: %s",
mark_tree_uninteresting(lookup_tree(entry.oid->hash));
break;
case OBJ_BLOB:
- mark_blob_uninteresting(lookup_blob(entry.oid->hash));
+ mark_blob_uninteresting(lookup_blob(entry.oid));
break;
default:
/* Subproject commit - not in this repository */
if (S_ISGITLINK(ce->ce_mode))
continue;
- blob = lookup_blob(ce->oid.hash);
+ blob = lookup_blob(&ce->oid);
if (!blob)
die("unable to add index blob to traversal");
add_pending_object_with_path(revs, &blob->object, "",
bufptr = nl + 1;
if (!strcmp(type, blob_type)) {
- item->tagged = &lookup_blob(oid.hash)->object;
+ item->tagged = &lookup_blob(&oid)->object;
} else if (!strcmp(type, tree_type)) {
item->tagged = &lookup_tree(oid.hash)->object;
} else if (!strcmp(type, commit_type)) {
obj = &tree->object;
}
else {
- struct blob *blob = lookup_blob(entry.oid->hash);
+ struct blob *blob = lookup_blob(entry.oid);
if (blob)
obj = &blob->object;
}