sha1_file: convert read_sha1_file to struct object_id
Convert read_sha1_file to take a pointer to struct object_id and rename it read_object_file. Do the same for read_sha1_file_extended. Convert one use in grep.c to use the new function without any other code change, since the pointer being passed is a void pointer that is already initialized with a pointer to struct object_id. Update the declaration and definitions of the modified functions, and apply the following semantic patch to convert the remaining callers: @@ expression E1, E2, E3; @@ - read_sha1_file(E1.hash, E2, E3) + read_object_file(&E1, E2, E3) @@ expression E1, E2, E3; @@ - read_sha1_file(E1->hash, E2, E3) + read_object_file(E1, E2, E3) @@ expression E1, E2, E3, E4; @@ - read_sha1_file_extended(E1.hash, E2, E3, E4) + read_object_file_extended(&E1, E2, E3, E4) @@ expression E1, E2, E3, E4; @@ - read_sha1_file_extended(E1->hash, E2, E3, E4) + read_object_file_extended(E1, E2, E3, E4) Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
02f0547eaa
commit
b4f5aca40e
4
apply.c
4
apply.c
@ -3180,7 +3180,7 @@ static int apply_binary(struct apply_state *state,
|
|||||||
unsigned long size;
|
unsigned long size;
|
||||||
char *result;
|
char *result;
|
||||||
|
|
||||||
result = read_sha1_file(oid.hash, &type, &size);
|
result = read_object_file(&oid, &type, &size);
|
||||||
if (!result)
|
if (!result)
|
||||||
return error(_("the necessary postimage %s for "
|
return error(_("the necessary postimage %s for "
|
||||||
"'%s' cannot be read"),
|
"'%s' cannot be read"),
|
||||||
@ -3242,7 +3242,7 @@ static int read_blob_object(struct strbuf *buf, const struct object_id *oid, uns
|
|||||||
unsigned long sz;
|
unsigned long sz;
|
||||||
char *result;
|
char *result;
|
||||||
|
|
||||||
result = read_sha1_file(oid->hash, &type, &sz);
|
result = read_object_file(oid, &type, &sz);
|
||||||
if (!result)
|
if (!result)
|
||||||
return -1;
|
return -1;
|
||||||
/* XXX read_sha1_file NUL-terminates */
|
/* XXX read_sha1_file NUL-terminates */
|
||||||
|
@ -72,7 +72,7 @@ void *object_file_to_archive(const struct archiver_args *args,
|
|||||||
const struct commit *commit = args->convert ? args->commit : NULL;
|
const struct commit *commit = args->convert ? args->commit : NULL;
|
||||||
|
|
||||||
path += args->baselen;
|
path += args->baselen;
|
||||||
buffer = read_sha1_file(oid->hash, type, sizep);
|
buffer = read_object_file(oid, type, sizep);
|
||||||
if (buffer && S_ISREG(mode)) {
|
if (buffer && S_ISREG(mode)) {
|
||||||
struct strbuf buf = STRBUF_INIT;
|
struct strbuf buf = STRBUF_INIT;
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
|
3
bisect.c
3
bisect.c
@ -132,7 +132,8 @@ static void show_list(const char *debug, int counted, int nr,
|
|||||||
unsigned flags = commit->object.flags;
|
unsigned flags = commit->object.flags;
|
||||||
enum object_type type;
|
enum object_type type;
|
||||||
unsigned long size;
|
unsigned long size;
|
||||||
char *buf = read_sha1_file(commit->object.oid.hash, &type, &size);
|
char *buf = read_object_file(&commit->object.oid, &type,
|
||||||
|
&size);
|
||||||
const char *subject_start;
|
const char *subject_start;
|
||||||
int subject_len;
|
int subject_len;
|
||||||
|
|
||||||
|
4
blame.c
4
blame.c
@ -297,7 +297,7 @@ static void fill_origin_blob(struct diff_options *opt,
|
|||||||
textconv_object(o->path, o->mode, &o->blob_oid, 1, &file->ptr, &file_size))
|
textconv_object(o->path, o->mode, &o->blob_oid, 1, &file->ptr, &file_size))
|
||||||
;
|
;
|
||||||
else
|
else
|
||||||
file->ptr = read_sha1_file(o->blob_oid.hash, &type,
|
file->ptr = read_object_file(&o->blob_oid, &type,
|
||||||
&file_size);
|
&file_size);
|
||||||
file->size = file_size;
|
file->size = file_size;
|
||||||
|
|
||||||
@ -1829,7 +1829,7 @@ void setup_scoreboard(struct blame_scoreboard *sb, const char *path, struct blam
|
|||||||
&sb->final_buf_size))
|
&sb->final_buf_size))
|
||||||
;
|
;
|
||||||
else
|
else
|
||||||
sb->final_buf = read_sha1_file(o->blob_oid.hash, &type,
|
sb->final_buf = read_object_file(&o->blob_oid, &type,
|
||||||
&sb->final_buf_size);
|
&sb->final_buf_size);
|
||||||
|
|
||||||
if (!sb->final_buf)
|
if (!sb->final_buf)
|
||||||
|
@ -32,7 +32,7 @@ static int filter_object(const char *path, unsigned mode,
|
|||||||
{
|
{
|
||||||
enum object_type type;
|
enum object_type type;
|
||||||
|
|
||||||
*buf = read_sha1_file(oid->hash, &type, size);
|
*buf = read_object_file(oid, &type, size);
|
||||||
if (!*buf)
|
if (!*buf)
|
||||||
return error(_("cannot read object %s '%s'"),
|
return error(_("cannot read object %s '%s'"),
|
||||||
oid_to_hex(oid), path);
|
oid_to_hex(oid), path);
|
||||||
@ -130,7 +130,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
|
|||||||
|
|
||||||
if (type == OBJ_BLOB)
|
if (type == OBJ_BLOB)
|
||||||
return stream_blob_to_fd(1, &oid, NULL, 0);
|
return stream_blob_to_fd(1, &oid, NULL, 0);
|
||||||
buf = read_sha1_file(oid.hash, &type, &size);
|
buf = read_object_file(&oid, &type, &size);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
die("Cannot read object %s", obj_name);
|
die("Cannot read object %s", obj_name);
|
||||||
|
|
||||||
@ -141,7 +141,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
|
|||||||
if (type_from_string(exp_type) == OBJ_BLOB) {
|
if (type_from_string(exp_type) == OBJ_BLOB) {
|
||||||
struct object_id blob_oid;
|
struct object_id blob_oid;
|
||||||
if (oid_object_info(&oid, NULL) == OBJ_TAG) {
|
if (oid_object_info(&oid, NULL) == OBJ_TAG) {
|
||||||
char *buffer = read_sha1_file(oid.hash, &type, &size);
|
char *buffer = read_object_file(&oid, &type,
|
||||||
|
&size);
|
||||||
const char *target;
|
const char *target;
|
||||||
if (!skip_prefix(buffer, "object ", &target) ||
|
if (!skip_prefix(buffer, "object ", &target) ||
|
||||||
get_oid_hex(target, &blob_oid))
|
get_oid_hex(target, &blob_oid))
|
||||||
@ -304,7 +305,8 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
|
|||||||
enum object_type type;
|
enum object_type type;
|
||||||
if (!textconv_object(data->rest, 0100644, oid,
|
if (!textconv_object(data->rest, 0100644, oid,
|
||||||
1, &contents, &size))
|
1, &contents, &size))
|
||||||
contents = read_sha1_file(oid->hash, &type,
|
contents = read_object_file(oid,
|
||||||
|
&type,
|
||||||
&size);
|
&size);
|
||||||
if (!contents)
|
if (!contents)
|
||||||
die("could not convert '%s' %s",
|
die("could not convert '%s' %s",
|
||||||
@ -321,7 +323,7 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
|
|||||||
unsigned long size;
|
unsigned long size;
|
||||||
void *contents;
|
void *contents;
|
||||||
|
|
||||||
contents = read_sha1_file(oid->hash, &type, &size);
|
contents = read_object_file(oid, &type, &size);
|
||||||
if (!contents)
|
if (!contents)
|
||||||
die("object %s disappeared", oid_to_hex(oid));
|
die("object %s disappeared", oid_to_hex(oid));
|
||||||
if (type != data->type)
|
if (type != data->type)
|
||||||
|
@ -306,7 +306,7 @@ static char *get_symlink(const struct object_id *oid, const char *path)
|
|||||||
} else {
|
} else {
|
||||||
enum object_type type;
|
enum object_type type;
|
||||||
unsigned long size;
|
unsigned long size;
|
||||||
data = read_sha1_file(oid->hash, &type, &size);
|
data = read_object_file(oid, &type, &size);
|
||||||
if (!data)
|
if (!data)
|
||||||
die(_("could not read object %s for symlink %s"),
|
die(_("could not read object %s for symlink %s"),
|
||||||
oid_to_hex(oid), path);
|
oid_to_hex(oid), path);
|
||||||
|
@ -237,7 +237,7 @@ static void export_blob(const struct object_id *oid)
|
|||||||
object = (struct object *)lookup_blob(oid);
|
object = (struct object *)lookup_blob(oid);
|
||||||
eaten = 0;
|
eaten = 0;
|
||||||
} else {
|
} else {
|
||||||
buf = read_sha1_file(oid->hash, &type, &size);
|
buf = read_object_file(oid, &type, &size);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
die ("Could not read blob %s", oid_to_hex(oid));
|
die ("Could not read blob %s", oid_to_hex(oid));
|
||||||
if (check_object_signature(oid, buf, size, type_name(type)) < 0)
|
if (check_object_signature(oid, buf, size, type_name(type)) < 0)
|
||||||
@ -682,7 +682,7 @@ static void handle_tag(const char *name, struct tag *tag)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = read_sha1_file(tag->object.oid.hash, &type, &size);
|
buf = read_object_file(&tag->object.oid, &type, &size);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
die ("Could not read tag %s", oid_to_hex(&tag->object.oid));
|
die ("Could not read tag %s", oid_to_hex(&tag->object.oid));
|
||||||
message = memmem(buf, size, "\n\n", 2);
|
message = memmem(buf, size, "\n\n", 2);
|
||||||
|
@ -488,7 +488,7 @@ static void fmt_merge_msg_sigs(struct strbuf *out)
|
|||||||
struct object_id *oid = origins.items[i].util;
|
struct object_id *oid = origins.items[i].util;
|
||||||
enum object_type type;
|
enum object_type type;
|
||||||
unsigned long size, len;
|
unsigned long size, len;
|
||||||
char *buf = read_sha1_file(oid->hash, &type, &size);
|
char *buf = read_object_file(oid, &type, &size);
|
||||||
struct strbuf sig = STRBUF_INIT;
|
struct strbuf sig = STRBUF_INIT;
|
||||||
|
|
||||||
if (!buf || type != OBJ_TAG)
|
if (!buf || type != OBJ_TAG)
|
||||||
|
@ -306,7 +306,7 @@ static void *lock_and_read_oid_file(const struct object_id *oid, enum object_typ
|
|||||||
void *data;
|
void *data;
|
||||||
|
|
||||||
grep_read_lock();
|
grep_read_lock();
|
||||||
data = read_sha1_file(oid->hash, type, size);
|
data = read_object_file(oid, type, size);
|
||||||
grep_read_unlock();
|
grep_read_unlock();
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
@ -815,7 +815,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
|
|||||||
die(_("cannot read existing object info %s"), oid_to_hex(oid));
|
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 !"), oid_to_hex(oid));
|
die(_("SHA1 COLLISION FOUND WITH %s !"), oid_to_hex(oid));
|
||||||
has_data = read_sha1_file(oid->hash, &has_type, &has_size);
|
has_data = read_object_file(oid, &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);
|
||||||
@ -1373,7 +1373,8 @@ static void fix_unresolved_deltas(struct hashfile *f)
|
|||||||
|
|
||||||
if (objects[d->obj_no].real_type != OBJ_REF_DELTA)
|
if (objects[d->obj_no].real_type != OBJ_REF_DELTA)
|
||||||
continue;
|
continue;
|
||||||
base_obj->data = read_sha1_file(d->oid.hash, &type, &base_obj->size);
|
base_obj->data = read_object_file(&d->oid, &type,
|
||||||
|
&base_obj->size);
|
||||||
if (!base_obj->data)
|
if (!base_obj->data)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -518,7 +518,7 @@ static int show_tag_object(const struct object_id *oid, struct rev_info *rev)
|
|||||||
{
|
{
|
||||||
unsigned long size;
|
unsigned long size;
|
||||||
enum object_type type;
|
enum object_type type;
|
||||||
char *buf = read_sha1_file(oid->hash, &type, &size);
|
char *buf = read_object_file(oid, &type, &size);
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
|
|
||||||
if (!buf)
|
if (!buf)
|
||||||
|
@ -60,7 +60,7 @@ static void *result(struct merge_list *entry, unsigned long *size)
|
|||||||
const char *path = entry->path;
|
const char *path = entry->path;
|
||||||
|
|
||||||
if (!entry->stage)
|
if (!entry->stage)
|
||||||
return read_sha1_file(entry->blob->object.oid.hash, &type, size);
|
return read_object_file(&entry->blob->object.oid, &type, size);
|
||||||
base = NULL;
|
base = NULL;
|
||||||
if (entry->stage == 1) {
|
if (entry->stage == 1) {
|
||||||
base = entry->blob;
|
base = entry->blob;
|
||||||
@ -82,7 +82,8 @@ static void *origin(struct merge_list *entry, unsigned long *size)
|
|||||||
enum object_type type;
|
enum object_type type;
|
||||||
while (entry) {
|
while (entry) {
|
||||||
if (entry->stage == 2)
|
if (entry->stage == 2)
|
||||||
return read_sha1_file(entry->blob->object.oid.hash, &type, size);
|
return read_object_file(&entry->blob->object.oid,
|
||||||
|
&type, size);
|
||||||
entry = entry->link;
|
entry = entry->link;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -23,7 +23,7 @@ static int verify_object(const struct object_id *oid, const char *expected_type)
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
enum object_type type;
|
enum object_type type;
|
||||||
unsigned long size;
|
unsigned long size;
|
||||||
void *buffer = read_sha1_file(oid->hash, &type, &size);
|
void *buffer = read_object_file(oid, &type, &size);
|
||||||
const unsigned char *repl = lookup_replace_object(oid->hash);
|
const unsigned char *repl = lookup_replace_object(oid->hash);
|
||||||
|
|
||||||
if (buffer) {
|
if (buffer) {
|
||||||
|
@ -122,7 +122,7 @@ static void copy_obj_to_fd(int fd, const struct object_id *oid)
|
|||||||
{
|
{
|
||||||
unsigned long size;
|
unsigned long size;
|
||||||
enum object_type type;
|
enum object_type type;
|
||||||
char *buf = read_sha1_file(oid->hash, &type, &size);
|
char *buf = read_object_file(oid, &type, &size);
|
||||||
if (buf) {
|
if (buf) {
|
||||||
if (size)
|
if (size)
|
||||||
write_or_die(fd, buf, size);
|
write_or_die(fd, buf, size);
|
||||||
@ -253,7 +253,7 @@ static int parse_reuse_arg(const struct option *opt, const char *arg, int unset)
|
|||||||
|
|
||||||
if (get_oid(arg, &object))
|
if (get_oid(arg, &object))
|
||||||
die(_("failed to resolve '%s' as a valid ref."), arg);
|
die(_("failed to resolve '%s' as a valid ref."), arg);
|
||||||
if (!(buf = read_sha1_file(object.hash, &type, &len))) {
|
if (!(buf = read_object_file(&object, &type, &len))) {
|
||||||
free(buf);
|
free(buf);
|
||||||
die(_("failed to read object '%s'."), arg);
|
die(_("failed to read object '%s'."), arg);
|
||||||
}
|
}
|
||||||
@ -608,7 +608,7 @@ static int append_edit(int argc, const char **argv, const char *prefix)
|
|||||||
/* Append buf to previous note contents */
|
/* Append buf to previous note contents */
|
||||||
unsigned long size;
|
unsigned long size;
|
||||||
enum object_type type;
|
enum object_type type;
|
||||||
char *prev_buf = read_sha1_file(note->hash, &type, &size);
|
char *prev_buf = read_object_file(note, &type, &size);
|
||||||
|
|
||||||
strbuf_grow(&d.buf, size + 1);
|
strbuf_grow(&d.buf, size + 1);
|
||||||
if (d.buf.len && prev_buf && size)
|
if (d.buf.len && prev_buf && size)
|
||||||
|
@ -122,11 +122,10 @@ static void *get_delta(struct object_entry *entry)
|
|||||||
void *buf, *base_buf, *delta_buf;
|
void *buf, *base_buf, *delta_buf;
|
||||||
enum object_type type;
|
enum object_type type;
|
||||||
|
|
||||||
buf = read_sha1_file(entry->idx.oid.hash, &type, &size);
|
buf = read_object_file(&entry->idx.oid, &type, &size);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
die("unable to read %s", oid_to_hex(&entry->idx.oid));
|
die("unable to read %s", oid_to_hex(&entry->idx.oid));
|
||||||
base_buf = read_sha1_file(entry->delta->idx.oid.hash, &type,
|
base_buf = read_object_file(&entry->delta->idx.oid, &type, &base_size);
|
||||||
&base_size);
|
|
||||||
if (!base_buf)
|
if (!base_buf)
|
||||||
die("unable to read %s",
|
die("unable to read %s",
|
||||||
oid_to_hex(&entry->delta->idx.oid));
|
oid_to_hex(&entry->delta->idx.oid));
|
||||||
@ -270,8 +269,7 @@ static unsigned long write_no_reuse_object(struct hashfile *f, struct object_ent
|
|||||||
(st = open_istream(&entry->idx.oid, &type, &size, NULL)) != NULL)
|
(st = open_istream(&entry->idx.oid, &type, &size, NULL)) != NULL)
|
||||||
buf = NULL;
|
buf = NULL;
|
||||||
else {
|
else {
|
||||||
buf = read_sha1_file(entry->idx.oid.hash, &type,
|
buf = read_object_file(&entry->idx.oid, &type, &size);
|
||||||
&size);
|
|
||||||
if (!buf)
|
if (!buf)
|
||||||
die(_("unable to read %s"),
|
die(_("unable to read %s"),
|
||||||
oid_to_hex(&entry->idx.oid));
|
oid_to_hex(&entry->idx.oid));
|
||||||
@ -1190,7 +1188,7 @@ static struct pbase_tree_cache *pbase_tree_get(const struct object_id *oid)
|
|||||||
/* Did not find one. Either we got a bogus request or
|
/* Did not find one. Either we got a bogus request or
|
||||||
* we need to read and perhaps cache.
|
* we need to read and perhaps cache.
|
||||||
*/
|
*/
|
||||||
data = read_sha1_file(oid->hash, &type, &size);
|
data = read_object_file(oid, &type, &size);
|
||||||
if (!data)
|
if (!data)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (type != OBJ_TREE) {
|
if (type != OBJ_TREE) {
|
||||||
@ -1870,8 +1868,7 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
|
|||||||
/* Load data if not already done */
|
/* Load data if not already done */
|
||||||
if (!trg->data) {
|
if (!trg->data) {
|
||||||
read_lock();
|
read_lock();
|
||||||
trg->data = read_sha1_file(trg_entry->idx.oid.hash, &type,
|
trg->data = read_object_file(&trg_entry->idx.oid, &type, &sz);
|
||||||
&sz);
|
|
||||||
read_unlock();
|
read_unlock();
|
||||||
if (!trg->data)
|
if (!trg->data)
|
||||||
die("object %s cannot be read",
|
die("object %s cannot be read",
|
||||||
@ -1884,8 +1881,7 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
|
|||||||
}
|
}
|
||||||
if (!src->data) {
|
if (!src->data) {
|
||||||
read_lock();
|
read_lock();
|
||||||
src->data = read_sha1_file(src_entry->idx.oid.hash, &type,
|
src->data = read_object_file(&src_entry->idx.oid, &type, &sz);
|
||||||
&sz);
|
|
||||||
read_unlock();
|
read_unlock();
|
||||||
if (!src->data) {
|
if (!src->data) {
|
||||||
if (src_entry->preferred_base) {
|
if (src_entry->preferred_base) {
|
||||||
|
@ -74,7 +74,7 @@ static int tree_is_complete(const struct object_id *oid)
|
|||||||
if (!tree->buffer) {
|
if (!tree->buffer) {
|
||||||
enum object_type type;
|
enum object_type type;
|
||||||
unsigned long size;
|
unsigned long size;
|
||||||
void *data = read_sha1_file(oid->hash, &type, &size);
|
void *data = read_object_file(oid, &type, &size);
|
||||||
if (!data) {
|
if (!data) {
|
||||||
tree->object.flags |= INCOMPLETE;
|
tree->object.flags |= INCOMPLETE;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -168,7 +168,7 @@ static void write_tag_body(int fd, const struct object_id *oid)
|
|||||||
enum object_type type;
|
enum object_type type;
|
||||||
char *buf, *sp;
|
char *buf, *sp;
|
||||||
|
|
||||||
buf = read_sha1_file(oid->hash, &type, &size);
|
buf = read_object_file(oid, &type, &size);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return;
|
return;
|
||||||
/* skip header */
|
/* skip header */
|
||||||
@ -304,7 +304,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)
|
|||||||
strbuf_addstr(sb, "object of unknown type");
|
strbuf_addstr(sb, "object of unknown type");
|
||||||
break;
|
break;
|
||||||
case OBJ_COMMIT:
|
case OBJ_COMMIT:
|
||||||
if ((buf = read_sha1_file(oid->hash, &type, &size)) != NULL) {
|
if ((buf = read_object_file(oid, &type, &size)) != NULL) {
|
||||||
subject_len = find_commit_subject(buf, &subject_start);
|
subject_len = find_commit_subject(buf, &subject_start);
|
||||||
strbuf_insert(sb, sb->len, subject_start, subject_len);
|
strbuf_insert(sb, sb->len, subject_start, subject_len);
|
||||||
} else {
|
} else {
|
||||||
|
@ -9,7 +9,7 @@ static char *create_temp_file(struct object_id *oid)
|
|||||||
unsigned long size;
|
unsigned long size;
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
buf = read_sha1_file(oid->hash, &type, &size);
|
buf = read_object_file(oid, &type, &size);
|
||||||
if (!buf || type != OBJ_BLOB)
|
if (!buf || type != OBJ_BLOB)
|
||||||
die("unable to read blob object %s", oid_to_hex(oid));
|
die("unable to read blob object %s", oid_to_hex(oid));
|
||||||
|
|
||||||
|
@ -422,7 +422,7 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,
|
|||||||
if (resolve_against_held(nr, &base_oid, delta_data, delta_size))
|
if (resolve_against_held(nr, &base_oid, delta_data, delta_size))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
base = read_sha1_file(base_oid.hash, &type, &base_size);
|
base = read_object_file(&base_oid, &type, &base_size);
|
||||||
if (!base) {
|
if (!base) {
|
||||||
error("failed to read delta-pack base object %s",
|
error("failed to read delta-pack base object %s",
|
||||||
oid_to_hex(&base_oid));
|
oid_to_hex(&base_oid));
|
||||||
|
@ -44,7 +44,7 @@ static int verify_commit(const char *name, unsigned flags)
|
|||||||
if (get_oid(name, &oid))
|
if (get_oid(name, &oid))
|
||||||
return error("commit '%s' not found.", name);
|
return error("commit '%s' not found.", name);
|
||||||
|
|
||||||
buf = read_sha1_file(oid.hash, &type, &size);
|
buf = read_object_file(&oid, &type, &size);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return error("%s: unable to read file.", name);
|
return error("%s: unable to read file.", name);
|
||||||
if (type != OBJ_COMMIT)
|
if (type != OBJ_COMMIT)
|
||||||
|
2
bundle.c
2
bundle.c
@ -222,7 +222,7 @@ static int is_tag_in_date_range(struct object *tag, struct rev_info *revs)
|
|||||||
if (revs->max_age == -1 && revs->min_age == -1)
|
if (revs->max_age == -1 && revs->min_age == -1)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
buf = read_sha1_file(tag->oid.hash, &type, &size);
|
buf = read_object_file(&tag->oid, &type, &size);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
goto out;
|
goto out;
|
||||||
line = memmem(buf, size, "\ntagger ", 8);
|
line = memmem(buf, size, "\ntagger ", 8);
|
||||||
|
6
cache.h
6
cache.h
@ -1185,12 +1185,12 @@ extern char *xdg_config_home(const char *filename);
|
|||||||
*/
|
*/
|
||||||
extern char *xdg_cache_home(const char *filename);
|
extern char *xdg_cache_home(const char *filename);
|
||||||
|
|
||||||
extern void *read_sha1_file_extended(const unsigned char *sha1,
|
extern void *read_object_file_extended(const struct object_id *oid,
|
||||||
enum object_type *type,
|
enum object_type *type,
|
||||||
unsigned long *size, int lookup_replace);
|
unsigned long *size, int lookup_replace);
|
||||||
static inline void *read_sha1_file(const unsigned char *sha1, enum object_type *type, unsigned long *size)
|
static inline void *read_object_file(const struct object_id *oid, enum object_type *type, unsigned long *size)
|
||||||
{
|
{
|
||||||
return read_sha1_file_extended(sha1, type, size, 1);
|
return read_object_file_extended(oid, type, size, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -306,7 +306,7 @@ static char *grab_blob(const struct object_id *oid, unsigned int mode,
|
|||||||
*size = fill_textconv(textconv, df, &blob);
|
*size = fill_textconv(textconv, df, &blob);
|
||||||
free_filespec(df);
|
free_filespec(df);
|
||||||
} else {
|
} else {
|
||||||
blob = read_sha1_file(oid->hash, &type, size);
|
blob = read_object_file(oid, &type, size);
|
||||||
if (type != OBJ_BLOB)
|
if (type != OBJ_BLOB)
|
||||||
die("object '%s' is not a blob!", oid_to_hex(oid));
|
die("object '%s' is not a blob!", oid_to_hex(oid));
|
||||||
}
|
}
|
||||||
|
6
commit.c
6
commit.c
@ -266,7 +266,7 @@ const void *get_commit_buffer(const struct commit *commit, unsigned long *sizep)
|
|||||||
if (!ret) {
|
if (!ret) {
|
||||||
enum object_type type;
|
enum object_type type;
|
||||||
unsigned long size;
|
unsigned long size;
|
||||||
ret = read_sha1_file(commit->object.oid.hash, &type, &size);
|
ret = read_object_file(&commit->object.oid, &type, &size);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
die("cannot read commit object %s",
|
die("cannot read commit object %s",
|
||||||
oid_to_hex(&commit->object.oid));
|
oid_to_hex(&commit->object.oid));
|
||||||
@ -383,7 +383,7 @@ int parse_commit_gently(struct commit *item, int quiet_on_missing)
|
|||||||
return -1;
|
return -1;
|
||||||
if (item->object.parsed)
|
if (item->object.parsed)
|
||||||
return 0;
|
return 0;
|
||||||
buffer = read_sha1_file(item->object.oid.hash, &type, &size);
|
buffer = read_object_file(&item->object.oid, &type, &size);
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
return quiet_on_missing ? -1 :
|
return quiet_on_missing ? -1 :
|
||||||
error("Could not read %s",
|
error("Could not read %s",
|
||||||
@ -1206,7 +1206,7 @@ static void handle_signed_tag(struct commit *parent, struct commit_extra_header
|
|||||||
desc = merge_remote_util(parent);
|
desc = merge_remote_util(parent);
|
||||||
if (!desc || !desc->obj)
|
if (!desc || !desc->obj)
|
||||||
return;
|
return;
|
||||||
buf = read_sha1_file(desc->obj->oid.hash, &type, &size);
|
buf = read_object_file(&desc->obj->oid, &type, &size);
|
||||||
if (!buf || type != OBJ_TAG)
|
if (!buf || type != OBJ_TAG)
|
||||||
goto free_return;
|
goto free_return;
|
||||||
len = parse_signature(buf, size);
|
len = parse_signature(buf, size);
|
||||||
|
2
config.c
2
config.c
@ -1488,7 +1488,7 @@ int git_config_from_blob_oid(config_fn_t fn,
|
|||||||
unsigned long size;
|
unsigned long size;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
buf = read_sha1_file(oid->hash, &type, &size);
|
buf = read_object_file(oid, &type, &size);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return error("unable to load config blob object '%s'", name);
|
return error("unable to load config blob object '%s'", name);
|
||||||
if (type != OBJ_BLOB) {
|
if (type != OBJ_BLOB) {
|
||||||
|
2
diff.c
2
diff.c
@ -3626,7 +3626,7 @@ int diff_populate_filespec(struct diff_filespec *s, unsigned int flags)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s->data = read_sha1_file(s->oid.hash, &type, &s->size);
|
s->data = read_object_file(&s->oid, &type, &s->size);
|
||||||
if (!s->data)
|
if (!s->data)
|
||||||
die("unable to read %s", oid_to_hex(&s->oid));
|
die("unable to read %s", oid_to_hex(&s->oid));
|
||||||
s->should_free = 1;
|
s->should_free = 1;
|
||||||
|
2
dir.c
2
dir.c
@ -243,7 +243,7 @@ static int do_read_blob(const struct object_id *oid, struct oid_stat *oid_stat,
|
|||||||
*size_out = 0;
|
*size_out = 0;
|
||||||
*data_out = NULL;
|
*data_out = NULL;
|
||||||
|
|
||||||
data = read_sha1_file(oid->hash, &type, &sz);
|
data = read_object_file(oid, &type, &sz);
|
||||||
if (!data || type != OBJ_BLOB) {
|
if (!data || type != OBJ_BLOB) {
|
||||||
free(data);
|
free(data);
|
||||||
return -1;
|
return -1;
|
||||||
|
2
entry.c
2
entry.c
@ -85,7 +85,7 @@ static int create_file(const char *path, unsigned int mode)
|
|||||||
static void *read_blob_entry(const struct cache_entry *ce, unsigned long *size)
|
static void *read_blob_entry(const struct cache_entry *ce, unsigned long *size)
|
||||||
{
|
{
|
||||||
enum object_type type;
|
enum object_type type;
|
||||||
void *blob_data = read_sha1_file(ce->oid.hash, &type, size);
|
void *blob_data = read_object_file(&ce->oid, &type, size);
|
||||||
|
|
||||||
if (blob_data) {
|
if (blob_data) {
|
||||||
if (type == OBJ_BLOB)
|
if (type == OBJ_BLOB)
|
||||||
|
@ -1412,7 +1412,7 @@ static void load_tree(struct tree_entry *root)
|
|||||||
die("Can't load tree %s", oid_to_hex(oid));
|
die("Can't load tree %s", oid_to_hex(oid));
|
||||||
} else {
|
} else {
|
||||||
enum object_type type;
|
enum object_type type;
|
||||||
buf = read_sha1_file(oid->hash, &type, &size);
|
buf = read_object_file(oid, &type, &size);
|
||||||
if (!buf || type != OBJ_TREE)
|
if (!buf || type != OBJ_TREE)
|
||||||
die("Can't load tree %s", oid_to_hex(oid));
|
die("Can't load tree %s", oid_to_hex(oid));
|
||||||
}
|
}
|
||||||
@ -2967,7 +2967,7 @@ static void cat_blob(struct object_entry *oe, struct object_id *oid)
|
|||||||
char *buf;
|
char *buf;
|
||||||
|
|
||||||
if (!oe || oe->pack_id == MAX_PACK_ID) {
|
if (!oe || oe->pack_id == MAX_PACK_ID) {
|
||||||
buf = read_sha1_file(oid->hash, &type, &size);
|
buf = read_object_file(oid, &type, &size);
|
||||||
} else {
|
} else {
|
||||||
type = oe->type;
|
type = oe->type;
|
||||||
buf = gfi_unpack_entry(oe, &size);
|
buf = gfi_unpack_entry(oe, &size);
|
||||||
@ -3072,7 +3072,7 @@ static struct object_entry *dereference(struct object_entry *oe,
|
|||||||
buf = gfi_unpack_entry(oe, &size);
|
buf = gfi_unpack_entry(oe, &size);
|
||||||
} else {
|
} else {
|
||||||
enum object_type unused;
|
enum object_type unused;
|
||||||
buf = read_sha1_file(oid->hash, &unused, &size);
|
buf = read_object_file(oid, &unused, &size);
|
||||||
}
|
}
|
||||||
if (!buf)
|
if (!buf)
|
||||||
die("Can't load object %s", oid_to_hex(oid));
|
die("Can't load object %s", oid_to_hex(oid));
|
||||||
|
2
fsck.c
2
fsck.c
@ -811,7 +811,7 @@ static int fsck_tag_buffer(struct tag *tag, const char *data,
|
|||||||
enum object_type type;
|
enum object_type type;
|
||||||
|
|
||||||
buffer = to_free =
|
buffer = to_free =
|
||||||
read_sha1_file(tag->object.oid.hash, &type, &size);
|
read_object_file(&tag->object.oid, &type, &size);
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
return report(options, &tag->object,
|
return report(options, &tag->object,
|
||||||
FSCK_MSG_MISSING_TAG_OBJECT,
|
FSCK_MSG_MISSING_TAG_OBJECT,
|
||||||
|
2
grep.c
2
grep.c
@ -2015,7 +2015,7 @@ static int grep_source_load_oid(struct grep_source *gs)
|
|||||||
enum object_type type;
|
enum object_type type;
|
||||||
|
|
||||||
grep_read_lock();
|
grep_read_lock();
|
||||||
gs->buf = read_sha1_file(gs->identifier, &type, &gs->size);
|
gs->buf = read_object_file(gs->identifier, &type, &gs->size);
|
||||||
grep_read_unlock();
|
grep_read_unlock();
|
||||||
|
|
||||||
if (!gs->buf)
|
if (!gs->buf)
|
||||||
|
@ -361,7 +361,7 @@ static void start_put(struct transfer_request *request)
|
|||||||
ssize_t size;
|
ssize_t size;
|
||||||
git_zstream stream;
|
git_zstream stream;
|
||||||
|
|
||||||
unpacked = read_sha1_file(request->obj->oid.hash, &type, &len);
|
unpacked = read_object_file(&request->obj->oid, &type, &len);
|
||||||
hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %lu", type_name(type), len) + 1;
|
hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %lu", type_name(type), len) + 1;
|
||||||
|
|
||||||
/* Set it up */
|
/* Set it up */
|
||||||
|
@ -224,7 +224,7 @@ static int read_mailmap_blob(struct string_list *map,
|
|||||||
if (get_oid(name, &oid) < 0)
|
if (get_oid(name, &oid) < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
buf = read_sha1_file(oid.hash, &type, &size);
|
buf = read_object_file(&oid, &type, &size);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return error("unable to read mailmap object at %s", name);
|
return error("unable to read mailmap object at %s", name);
|
||||||
if (type != OBJ_BLOB)
|
if (type != OBJ_BLOB)
|
||||||
|
@ -54,7 +54,7 @@ static void *fill_tree_desc_strict(struct tree_desc *desc,
|
|||||||
enum object_type type;
|
enum object_type type;
|
||||||
unsigned long size;
|
unsigned long size;
|
||||||
|
|
||||||
buffer = read_sha1_file(hash->hash, &type, &size);
|
buffer = read_object_file(hash, &type, &size);
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
die("unable to read tree (%s)", oid_to_hex(hash));
|
die("unable to read tree (%s)", oid_to_hex(hash));
|
||||||
if (type != OBJ_TREE)
|
if (type != OBJ_TREE)
|
||||||
@ -180,7 +180,7 @@ static int splice_tree(const struct object_id *oid1, const char *prefix,
|
|||||||
if (*subpath)
|
if (*subpath)
|
||||||
subpath++;
|
subpath++;
|
||||||
|
|
||||||
buf = read_sha1_file(oid1->hash, &type, &sz);
|
buf = read_object_file(oid1, &type, &sz);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
die("cannot read tree %s", oid_to_hex(oid1));
|
die("cannot read tree %s", oid_to_hex(oid1));
|
||||||
init_tree_desc(&desc, buf, sz);
|
init_tree_desc(&desc, buf, sz);
|
||||||
|
@ -11,7 +11,7 @@ static int fill_mmfile_blob(mmfile_t *f, struct blob *obj)
|
|||||||
unsigned long size;
|
unsigned long size;
|
||||||
enum object_type type;
|
enum object_type type;
|
||||||
|
|
||||||
buf = read_sha1_file(obj->object.oid.hash, &type, &size);
|
buf = read_object_file(&obj->object.oid, &type, &size);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return -1;
|
return -1;
|
||||||
if (type != OBJ_BLOB) {
|
if (type != OBJ_BLOB) {
|
||||||
@ -66,7 +66,7 @@ void *merge_blobs(const char *path, struct blob *base, struct blob *our, struct
|
|||||||
return NULL;
|
return NULL;
|
||||||
if (!our)
|
if (!our)
|
||||||
our = their;
|
our = their;
|
||||||
return read_sha1_file(our->object.oid.hash, &type, size);
|
return read_object_file(&our->object.oid, &type, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fill_mmfile_blob(&f1, our) < 0)
|
if (fill_mmfile_blob(&f1, our) < 0)
|
||||||
|
@ -842,7 +842,7 @@ static int update_file_flags(struct merge_options *o,
|
|||||||
goto update_index;
|
goto update_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = read_sha1_file(oid->hash, &type, &size);
|
buf = read_object_file(oid, &type, &size);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return err(o, _("cannot read object %s '%s'"), oid_to_hex(oid), path);
|
return err(o, _("cannot read object %s '%s'"), oid_to_hex(oid), path);
|
||||||
if (type != OBJ_BLOB) {
|
if (type != OBJ_BLOB) {
|
||||||
@ -1656,7 +1656,7 @@ static int read_oid_strbuf(struct merge_options *o,
|
|||||||
void *buf;
|
void *buf;
|
||||||
enum object_type type;
|
enum object_type type;
|
||||||
unsigned long size;
|
unsigned long size;
|
||||||
buf = read_sha1_file(oid->hash, &type, &size);
|
buf = read_object_file(oid, &type, &size);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return err(o, _("cannot read object %s"), oid_to_hex(oid));
|
return err(o, _("cannot read object %s"), oid_to_hex(oid));
|
||||||
if (type != OBJ_BLOB) {
|
if (type != OBJ_BLOB) {
|
||||||
|
@ -77,7 +77,7 @@ char *notes_cache_get(struct notes_cache *c, struct object_id *key_oid,
|
|||||||
value_oid = get_note(&c->tree, key_oid);
|
value_oid = get_note(&c->tree, key_oid);
|
||||||
if (!value_oid)
|
if (!value_oid)
|
||||||
return NULL;
|
return NULL;
|
||||||
value = read_sha1_file(value_oid->hash, &type, &size);
|
value = read_object_file(value_oid, &type, &size);
|
||||||
|
|
||||||
*outsize = size;
|
*outsize = size;
|
||||||
return value;
|
return value;
|
||||||
|
@ -322,7 +322,7 @@ static void write_note_to_worktree(const struct object_id *obj,
|
|||||||
{
|
{
|
||||||
enum object_type type;
|
enum object_type type;
|
||||||
unsigned long size;
|
unsigned long size;
|
||||||
void *buf = read_sha1_file(note->hash, &type, &size);
|
void *buf = read_object_file(note, &type, &size);
|
||||||
|
|
||||||
if (!buf)
|
if (!buf)
|
||||||
die("cannot read note %s for object %s",
|
die("cannot read note %s for object %s",
|
||||||
|
8
notes.c
8
notes.c
@ -796,13 +796,13 @@ int combine_notes_concatenate(struct object_id *cur_oid,
|
|||||||
|
|
||||||
/* read in both note blob objects */
|
/* read in both note blob objects */
|
||||||
if (!is_null_oid(new_oid))
|
if (!is_null_oid(new_oid))
|
||||||
new_msg = read_sha1_file(new_oid->hash, &new_type, &new_len);
|
new_msg = read_object_file(new_oid, &new_type, &new_len);
|
||||||
if (!new_msg || !new_len || new_type != OBJ_BLOB) {
|
if (!new_msg || !new_len || new_type != OBJ_BLOB) {
|
||||||
free(new_msg);
|
free(new_msg);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!is_null_oid(cur_oid))
|
if (!is_null_oid(cur_oid))
|
||||||
cur_msg = read_sha1_file(cur_oid->hash, &cur_type, &cur_len);
|
cur_msg = read_object_file(cur_oid, &cur_type, &cur_len);
|
||||||
if (!cur_msg || !cur_len || cur_type != OBJ_BLOB) {
|
if (!cur_msg || !cur_len || cur_type != OBJ_BLOB) {
|
||||||
free(cur_msg);
|
free(cur_msg);
|
||||||
free(new_msg);
|
free(new_msg);
|
||||||
@ -858,7 +858,7 @@ static int string_list_add_note_lines(struct string_list *list,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* read_sha1_file NUL-terminates */
|
/* read_sha1_file NUL-terminates */
|
||||||
data = read_sha1_file(oid->hash, &t, &len);
|
data = read_object_file(oid, &t, &len);
|
||||||
if (t != OBJ_BLOB || !data || !len) {
|
if (t != OBJ_BLOB || !data || !len) {
|
||||||
free(data);
|
free(data);
|
||||||
return t != OBJ_BLOB || !data;
|
return t != OBJ_BLOB || !data;
|
||||||
@ -1217,7 +1217,7 @@ static void format_note(struct notes_tree *t, const struct object_id *object_oid
|
|||||||
if (!oid)
|
if (!oid)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!(msg = read_sha1_file(oid->hash, &type, &msglen)) || type != OBJ_BLOB) {
|
if (!(msg = read_object_file(oid, &type, &msglen)) || type != OBJ_BLOB) {
|
||||||
free(msg);
|
free(msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
2
object.c
2
object.c
@ -266,7 +266,7 @@ struct object *parse_object(const struct object_id *oid)
|
|||||||
return lookup_object(oid->hash);
|
return lookup_object(oid->hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer = read_sha1_file(oid->hash, &type, &size);
|
buffer = read_object_file(oid, &type, &size);
|
||||||
if (buffer) {
|
if (buffer) {
|
||||||
struct object_id reploid;
|
struct object_id reploid;
|
||||||
hashcpy(reploid.hash, repl);
|
hashcpy(reploid.hash, repl);
|
||||||
|
@ -184,7 +184,7 @@ static int ce_compare_link(const struct cache_entry *ce, size_t expected_size)
|
|||||||
if (strbuf_readlink(&sb, ce->name, expected_size))
|
if (strbuf_readlink(&sb, ce->name, expected_size))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
buffer = read_sha1_file(ce->oid.hash, &type, &size);
|
buffer = read_object_file(&ce->oid, &type, &size);
|
||||||
if (buffer) {
|
if (buffer) {
|
||||||
if (size == sb.len)
|
if (size == sb.len)
|
||||||
match = memcmp(buffer, sb.buf, size);
|
match = memcmp(buffer, sb.buf, size);
|
||||||
@ -2683,7 +2683,7 @@ void *read_blob_data_from_index(const struct index_state *istate,
|
|||||||
}
|
}
|
||||||
if (pos < 0)
|
if (pos < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
data = read_sha1_file(istate->cache[pos]->oid.hash, &type, &sz);
|
data = read_object_file(&istate->cache[pos]->oid, &type, &sz);
|
||||||
if (!data || type != OBJ_BLOB) {
|
if (!data || type != OBJ_BLOB) {
|
||||||
free(data);
|
free(data);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -728,7 +728,7 @@ int verify_ref_format(struct ref_format *format)
|
|||||||
static void *get_obj(const struct object_id *oid, struct object **obj, unsigned long *sz, int *eaten)
|
static void *get_obj(const struct object_id *oid, struct object **obj, unsigned long *sz, int *eaten)
|
||||||
{
|
{
|
||||||
enum object_type type;
|
enum object_type type;
|
||||||
void *buf = read_sha1_file(oid->hash, &type, sz);
|
void *buf = read_object_file(oid, &type, sz);
|
||||||
|
|
||||||
if (buf)
|
if (buf)
|
||||||
*obj = parse_object_buffer(oid, type, *sz, buf, eaten);
|
*obj = parse_object_buffer(oid, type, *sz, buf, eaten);
|
||||||
|
@ -61,7 +61,7 @@ static char *read_ref_note(const struct object_id *oid)
|
|||||||
init_notes(NULL, notes_ref, NULL, 0);
|
init_notes(NULL, notes_ref, NULL, 0);
|
||||||
if (!(note_oid = get_note(NULL, oid)))
|
if (!(note_oid = get_note(NULL, oid)))
|
||||||
return NULL; /* note tree not found */
|
return NULL; /* note tree not found */
|
||||||
if (!(msg = read_sha1_file(note_oid->hash, &type, &msglen)))
|
if (!(msg = read_object_file(note_oid, &type, &msglen)))
|
||||||
error("Empty notes tree. %s", notes_ref);
|
error("Empty notes tree. %s", notes_ref);
|
||||||
else if (!msglen || type != OBJ_BLOB) {
|
else if (!msglen || type != OBJ_BLOB) {
|
||||||
error("Note contains unusable content. "
|
error("Note contains unusable content. "
|
||||||
@ -108,7 +108,7 @@ static int note2mark_cb(const struct object_id *object_oid,
|
|||||||
enum object_type type;
|
enum object_type type;
|
||||||
struct rev_note note;
|
struct rev_note note;
|
||||||
|
|
||||||
if (!(msg = read_sha1_file(note_oid->hash, &type, &msglen)) ||
|
if (!(msg = read_object_file(note_oid, &type, &msglen)) ||
|
||||||
!msglen || type != OBJ_BLOB) {
|
!msglen || type != OBJ_BLOB) {
|
||||||
free(msg);
|
free(msg);
|
||||||
return 1;
|
return 1;
|
||||||
|
2
rerere.c
2
rerere.c
@ -981,7 +981,7 @@ static int handle_cache(const char *path, unsigned char *sha1, const char *outpu
|
|||||||
break;
|
break;
|
||||||
i = ce_stage(ce) - 1;
|
i = ce_stage(ce) - 1;
|
||||||
if (!mmfile[i].ptr) {
|
if (!mmfile[i].ptr) {
|
||||||
mmfile[i].ptr = read_sha1_file(ce->oid.hash, &type,
|
mmfile[i].ptr = read_object_file(&ce->oid, &type,
|
||||||
&size);
|
&size);
|
||||||
mmfile[i].size = size;
|
mmfile[i].size = size;
|
||||||
}
|
}
|
||||||
|
14
sha1_file.c
14
sha1_file.c
@ -1363,7 +1363,7 @@ int pretend_object_file(void *buf, unsigned long len, enum object_type type,
|
|||||||
* deal with them should arrange to call read_object() and give error
|
* deal with them should arrange to call read_object() and give error
|
||||||
* messages themselves.
|
* messages themselves.
|
||||||
*/
|
*/
|
||||||
void *read_sha1_file_extended(const unsigned char *sha1,
|
void *read_object_file_extended(const struct object_id *oid,
|
||||||
enum object_type *type,
|
enum object_type *type,
|
||||||
unsigned long *size,
|
unsigned long *size,
|
||||||
int lookup_replace)
|
int lookup_replace)
|
||||||
@ -1372,8 +1372,8 @@ void *read_sha1_file_extended(const unsigned char *sha1,
|
|||||||
const struct packed_git *p;
|
const struct packed_git *p;
|
||||||
const char *path;
|
const char *path;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
const unsigned char *repl = lookup_replace ? lookup_replace_object(sha1)
|
const unsigned char *repl = lookup_replace ? lookup_replace_object(oid->hash)
|
||||||
: sha1;
|
: oid->hash;
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
data = read_object(repl, type, size);
|
data = read_object(repl, type, size);
|
||||||
@ -1381,12 +1381,12 @@ void *read_sha1_file_extended(const unsigned char *sha1,
|
|||||||
return data;
|
return data;
|
||||||
|
|
||||||
if (errno && errno != ENOENT)
|
if (errno && errno != ENOENT)
|
||||||
die_errno("failed to read object %s", sha1_to_hex(sha1));
|
die_errno("failed to read object %s", oid_to_hex(oid));
|
||||||
|
|
||||||
/* die if we replaced an object with one that does not exist */
|
/* die if we replaced an object with one that does not exist */
|
||||||
if (repl != sha1)
|
if (repl != oid->hash)
|
||||||
die("replacement %s not found for %s",
|
die("replacement %s not found for %s",
|
||||||
sha1_to_hex(repl), sha1_to_hex(sha1));
|
sha1_to_hex(repl), oid_to_hex(oid));
|
||||||
|
|
||||||
if (!stat_sha1_file(repl, &st, &path))
|
if (!stat_sha1_file(repl, &st, &path))
|
||||||
die("loose object %s (stored in %s) is corrupt",
|
die("loose object %s (stored in %s) is corrupt",
|
||||||
@ -1415,7 +1415,7 @@ void *read_object_with_reference(const struct object_id *oid,
|
|||||||
int ref_length = -1;
|
int ref_length = -1;
|
||||||
const char *ref_type = NULL;
|
const char *ref_type = NULL;
|
||||||
|
|
||||||
buffer = read_sha1_file(actual_oid.hash, &type, &isize);
|
buffer = read_object_file(&actual_oid, &type, &isize);
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (type == required_type) {
|
if (type == required_type) {
|
||||||
|
@ -492,7 +492,7 @@ static struct stream_vtbl incore_vtbl = {
|
|||||||
|
|
||||||
static open_method_decl(incore)
|
static open_method_decl(incore)
|
||||||
{
|
{
|
||||||
st->u.incore.buf = read_sha1_file_extended(oid->hash, type, &st->size, 0);
|
st->u.incore.buf = read_object_file_extended(oid, type, &st->size, 0);
|
||||||
st->u.incore.read_ptr = 0;
|
st->u.incore.read_ptr = 0;
|
||||||
st->vtbl = &incore_vtbl;
|
st->vtbl = &incore_vtbl;
|
||||||
|
|
||||||
|
@ -520,7 +520,7 @@ static const struct submodule *config_from(struct submodule_cache *cache,
|
|||||||
if (submodule)
|
if (submodule)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
config = read_sha1_file(oid.hash, &type, &config_size);
|
config = read_object_file(&oid, &type, &config_size);
|
||||||
if (!config || type != OBJ_BLOB)
|
if (!config || type != OBJ_BLOB)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
4
tag.c
4
tag.c
@ -49,7 +49,7 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,
|
|||||||
find_unique_abbrev(oid, DEFAULT_ABBREV),
|
find_unique_abbrev(oid, DEFAULT_ABBREV),
|
||||||
type_name(type));
|
type_name(type));
|
||||||
|
|
||||||
buf = read_sha1_file(oid->hash, &type, &size);
|
buf = read_object_file(oid, &type, &size);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return error("%s: unable to read file.",
|
return error("%s: unable to read file.",
|
||||||
name_to_report ?
|
name_to_report ?
|
||||||
@ -182,7 +182,7 @@ int parse_tag(struct tag *item)
|
|||||||
|
|
||||||
if (item->object.parsed)
|
if (item->object.parsed)
|
||||||
return 0;
|
return 0;
|
||||||
data = read_sha1_file(item->object.oid.hash, &type, &size);
|
data = read_object_file(&item->object.oid, &type, &size);
|
||||||
if (!data)
|
if (!data)
|
||||||
return error("Could not read %s",
|
return error("Could not read %s",
|
||||||
oid_to_hex(&item->object.oid));
|
oid_to_hex(&item->object.oid));
|
||||||
|
@ -713,7 +713,7 @@ enum follow_symlinks_result get_tree_entry_follow_symlinks(unsigned char *tree_s
|
|||||||
*/
|
*/
|
||||||
retval = DANGLING_SYMLINK;
|
retval = DANGLING_SYMLINK;
|
||||||
|
|
||||||
contents = read_sha1_file(current_tree_oid.hash, &type,
|
contents = read_object_file(¤t_tree_oid, &type,
|
||||||
&link_len);
|
&link_len);
|
||||||
|
|
||||||
if (!contents)
|
if (!contents)
|
||||||
|
2
tree.c
2
tree.c
@ -219,7 +219,7 @@ int parse_tree_gently(struct tree *item, int quiet_on_missing)
|
|||||||
|
|
||||||
if (item->object.parsed)
|
if (item->object.parsed)
|
||||||
return 0;
|
return 0;
|
||||||
buffer = read_sha1_file(item->object.oid.hash, &type, &size);
|
buffer = read_object_file(&item->object.oid, &type, &size);
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
return quiet_on_missing ? -1 :
|
return quiet_on_missing ? -1 :
|
||||||
error("Could not read %s",
|
error("Could not read %s",
|
||||||
|
@ -191,7 +191,7 @@ void read_mmblob(mmfile_t *ptr, const struct object_id *oid)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ptr->ptr = read_sha1_file(oid->hash, &type, &size);
|
ptr->ptr = read_object_file(oid, &type, &size);
|
||||||
if (!ptr->ptr || type != OBJ_BLOB)
|
if (!ptr->ptr || type != OBJ_BLOB)
|
||||||
die("unable to read blob object %s", oid_to_hex(oid));
|
die("unable to read blob object %s", oid_to_hex(oid));
|
||||||
ptr->size = size;
|
ptr->size = size;
|
||||||
|
Loading…
Reference in New Issue
Block a user