Commit a5bbc299 authored by Junio C Hamano's avatar Junio C Hamano

Merge branch 'bc/object-id'

Conversion from uchar[20] to struct object_id continues.

* bc/object-id: (36 commits)
  convert: convert to struct object_id
  sha1_file: introduce a constant for max header length
  Convert lookup_replace_object to struct object_id
  sha1_file: convert read_sha1_file to struct object_id
  sha1_file: convert read_object_with_reference to object_id
  tree-walk: convert tree entry functions to object_id
  streaming: convert istream internals to struct object_id
  tree-walk: convert get_tree_entry_follow_symlinks internals to object_id
  builtin/notes: convert static functions to object_id
  builtin/fmt-merge-msg: convert remaining code to object_id
  sha1_file: convert sha1_object_info* to object_id
  Convert remaining callers of sha1_object_info_extended to object_id
  packfile: convert unpack_entry to struct object_id
  sha1_file: convert retry_bad_packed_offset to struct object_id
  sha1_file: convert assert_sha1_type to object_id
  builtin/mktree: convert to struct object_id
  streaming: convert open_istream to use struct object_id
  sha1_file: convert check_sha1_signature to struct object_id
  sha1_file: convert read_loose_object to use struct object_id
  builtin/index-pack: convert struct ref_delta_entry to object_id
  ...
parents 78c20b8f 1a750441
......@@ -3180,7 +3180,7 @@ static int apply_binary(struct apply_state *state,
unsigned long size;
char *result;
result = read_sha1_file(oid.hash, &type, &size);
result = read_object_file(&oid, &type, &size);
if (!result)
return error(_("the necessary postimage %s for "
"'%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;
char *result;
result = read_sha1_file(oid->hash, &type, &sz);
result = read_object_file(oid, &type, &sz);
if (!result)
return -1;
/* XXX read_sha1_file NUL-terminates */
......
......@@ -111,7 +111,7 @@ static void write_trailer(void)
* queues up writes, so that all our write(2) calls write exactly one
* full block; pads writes to RECORDSIZE
*/
static int stream_blocked(const unsigned char *sha1)
static int stream_blocked(const struct object_id *oid)
{
struct git_istream *st;
enum object_type type;
......@@ -119,9 +119,9 @@ static int stream_blocked(const unsigned char *sha1)
char buf[BLOCKSIZE];
ssize_t readlen;
st = open_istream(sha1, &type, &sz, NULL);
st = open_istream(oid, &type, &sz, NULL);
if (!st)
return error("cannot stream blob %s", sha1_to_hex(sha1));
return error("cannot stream blob %s", oid_to_hex(oid));
for (;;) {
readlen = read_istream(st, buf, sizeof(buf));
if (readlen <= 0)
......@@ -218,7 +218,7 @@ static void prepare_header(struct archiver_args *args,
}
static void write_extended_header(struct archiver_args *args,
const unsigned char *sha1,
const struct object_id *oid,
const void *buffer, unsigned long size)
{
struct ustar_header header;
......@@ -226,14 +226,14 @@ static void write_extended_header(struct archiver_args *args,
memset(&header, 0, sizeof(header));
*header.typeflag = TYPEFLAG_EXT_HEADER;
mode = 0100666;
xsnprintf(header.name, sizeof(header.name), "%s.paxheader", sha1_to_hex(sha1));
xsnprintf(header.name, sizeof(header.name), "%s.paxheader", oid_to_hex(oid));
prepare_header(args, &header, mode, size);
write_blocked(&header, sizeof(header));
write_blocked(buffer, size);
}
static int write_tar_entry(struct archiver_args *args,
const unsigned char *sha1,
const struct object_id *oid,
const char *path, size_t pathlen,
unsigned int mode)
{
......@@ -257,7 +257,7 @@ static int write_tar_entry(struct archiver_args *args,
mode = (mode | ((mode & 0100) ? 0777 : 0666)) & ~tar_umask;
} else {
return error("unsupported file mode: 0%o (SHA1: %s)",
mode, sha1_to_hex(sha1));
mode, oid_to_hex(oid));
}
if (pathlen > sizeof(header.name)) {
size_t plen = get_path_prefix(path, pathlen,
......@@ -268,7 +268,7 @@ static int write_tar_entry(struct archiver_args *args,
memcpy(header.name, path + plen + 1, rest);
} else {
xsnprintf(header.name, sizeof(header.name), "%s.data",
sha1_to_hex(sha1));
oid_to_hex(oid));
strbuf_append_ext_header(&ext_header, "path",
path, pathlen);
}
......@@ -276,14 +276,14 @@ static int write_tar_entry(struct archiver_args *args,
memcpy(header.name, path, pathlen);
if (S_ISREG(mode) && !args->convert &&
sha1_object_info(sha1, &size) == OBJ_BLOB &&
oid_object_info(oid, &size) == OBJ_BLOB &&
size > big_file_threshold)
buffer = NULL;
else if (S_ISLNK(mode) || S_ISREG(mode)) {
enum object_type type;
buffer = sha1_file_to_archive(args, path, sha1, old_mode, &type, &size);
buffer = object_file_to_archive(args, path, oid, old_mode, &type, &size);
if (!buffer)
return error("cannot read %s", sha1_to_hex(sha1));
return error("cannot read %s", oid_to_hex(oid));
} else {
buffer = NULL;
size = 0;
......@@ -292,7 +292,7 @@ static int write_tar_entry(struct archiver_args *args,
if (S_ISLNK(mode)) {
if (size > sizeof(header.linkname)) {
xsnprintf(header.linkname, sizeof(header.linkname),
"see %s.paxheader", sha1_to_hex(sha1));
"see %s.paxheader", oid_to_hex(oid));
strbuf_append_ext_header(&ext_header, "linkpath",
buffer, size);
} else
......@@ -308,7 +308,7 @@ static int write_tar_entry(struct archiver_args *args,
prepare_header(args, &header, mode, size_in_header);
if (ext_header.len > 0) {
write_extended_header(args, sha1, ext_header.buf,
write_extended_header(args, oid, ext_header.buf,
ext_header.len);
}
strbuf_release(&ext_header);
......@@ -317,7 +317,7 @@ static int write_tar_entry(struct archiver_args *args,
if (buffer)
write_blocked(buffer, size);
else
err = stream_blocked(sha1);
err = stream_blocked(oid);
}
free(buffer);
return err;
......
......@@ -276,7 +276,7 @@ static int entry_is_binary(const char *path, const void *buffer, size_t size)
#define STREAM_BUFFER_SIZE (1024 * 16)
static int write_zip_entry(struct archiver_args *args,
const unsigned char *sha1,
const struct object_id *oid,
const char *path, size_t pathlen,
unsigned int mode)
{
......@@ -314,7 +314,7 @@ static int write_zip_entry(struct archiver_args *args,
if (pathlen > 0xffff) {
return error("path too long (%d chars, SHA1: %s): %s",
(int)pathlen, sha1_to_hex(sha1), path);
(int)pathlen, oid_to_hex(oid), path);
}
if (S_ISDIR(mode) || S_ISGITLINK(mode)) {
......@@ -325,7 +325,7 @@ static int write_zip_entry(struct archiver_args *args,
compressed_size = 0;
buffer = NULL;
} else if (S_ISREG(mode) || S_ISLNK(mode)) {
enum object_type type = sha1_object_info(sha1, &size);
enum object_type type = oid_object_info(oid, &size);
method = 0;
attr2 = S_ISLNK(mode) ? ((mode | 0777) << 16) :
......@@ -337,18 +337,18 @@ static int write_zip_entry(struct archiver_args *args,
if (S_ISREG(mode) && type == OBJ_BLOB && !args->convert &&
size > big_file_threshold) {
stream = open_istream(sha1, &type, &size, NULL);
stream = open_istream(oid, &type, &size, NULL);
if (!stream)
return error("cannot stream blob %s",
sha1_to_hex(sha1));
oid_to_hex(oid));
flags |= ZIP_STREAM;
out = buffer = NULL;
} else {
buffer = sha1_file_to_archive(args, path, sha1, mode,
&type, &size);
buffer = object_file_to_archive(args, path, oid, mode,
&type, &size);
if (!buffer)
return error("cannot read %s",
sha1_to_hex(sha1));
oid_to_hex(oid));
crc = crc32(crc, buffer, size);
is_binary = entry_is_binary(path_without_prefix,
buffer, size);
......@@ -357,7 +357,7 @@ static int write_zip_entry(struct archiver_args *args,
compressed_size = (method == 0) ? size : 0;
} else {
return error("unsupported file mode: 0%o (SHA1: %s)", mode,
sha1_to_hex(sha1));
oid_to_hex(oid));
}
if (creator_version > max_creator_version)
......
......@@ -63,16 +63,16 @@ static void format_subst(const struct commit *commit,
free(to_free);
}
void *sha1_file_to_archive(const struct archiver_args *args,
const char *path, const unsigned char *sha1,
unsigned int mode, enum object_type *type,
unsigned long *sizep)
void *object_file_to_archive(const struct archiver_args *args,
const char *path, const struct object_id *oid,
unsigned int mode, enum object_type *type,
unsigned long *sizep)
{
void *buffer;
const struct commit *commit = args->convert ? args->commit : NULL;
path += args->baselen;
buffer = read_sha1_file(sha1, type, sizep);
buffer = read_object_file(oid, type, sizep);
if (buffer && S_ISREG(mode)) {
struct strbuf buf = STRBUF_INIT;
size_t size = 0;
......@@ -121,7 +121,7 @@ static int check_attr_export_subst(const struct attr_check *check)
return check && ATTR_TRUE(check->items[1].value);
}
static int write_archive_entry(const unsigned char *sha1, const char *base,
static int write_archive_entry(const struct object_id *oid, const char *base,
int baselen, const char *filename, unsigned mode, int stage,
void *context)
{
......@@ -153,7 +153,7 @@ static int write_archive_entry(const unsigned char *sha1, const char *base,
if (S_ISDIR(mode) || S_ISGITLINK(mode)) {
if (args->verbose)
fprintf(stderr, "%.*s\n", (int)path.len, path.buf);
err = write_entry(args, sha1, path.buf, path.len, mode);
err = write_entry(args, oid, path.buf, path.len, mode);
if (err)
return err;
return (S_ISDIR(mode) ? READ_TREE_RECURSIVE : 0);
......@@ -161,7 +161,7 @@ static int write_archive_entry(const unsigned char *sha1, const char *base,
if (args->verbose)
fprintf(stderr, "%.*s\n", (int)path.len, path.buf);
return write_entry(args, sha1, path.buf, path.len, mode);
return write_entry(args, oid, path.buf, path.len, mode);
}
static void queue_directory(const unsigned char *sha1,
......@@ -191,14 +191,14 @@ static int write_directory(struct archiver_context *c)
d->path[d->len - 1] = '\0'; /* no trailing slash */
ret =
write_directory(c) ||
write_archive_entry(d->oid.hash, d->path, d->baselen,
write_archive_entry(&d->oid, d->path, d->baselen,
d->path + d->baselen, d->mode,
d->stage, c) != READ_TREE_RECURSIVE;
free(d);
return ret ? -1 : 0;
}
static int queue_or_write_archive_entry(const unsigned char *sha1,
static int queue_or_write_archive_entry(const struct object_id *oid,
struct strbuf *base, const char *filename,
unsigned mode, int stage, void *context)
{
......@@ -224,14 +224,14 @@ static int queue_or_write_archive_entry(const unsigned char *sha1,
if (check_attr_export_ignore(check))
return 0;
queue_directory(sha1, base, filename,
queue_directory(oid->hash, base, filename,
mode, stage, c);
return READ_TREE_RECURSIVE;
}
if (write_directory(c))
return -1;
return write_archive_entry(sha1, base->buf, base->len, filename, mode,
return write_archive_entry(oid, base->buf, base->len, filename, mode,
stage, context);
}
......@@ -250,7 +250,7 @@ int write_archive_entries(struct archiver_args *args,
len--;
if (args->verbose)
fprintf(stderr, "%.*s\n", (int)len, args->base);
err = write_entry(args, args->tree->object.oid.hash, args->base,
err = write_entry(args, &args->tree->object.oid, args->base,
len, 040777);
if (err)
return err;
......@@ -303,7 +303,7 @@ static const struct archiver *lookup_archiver(const char *name)
return NULL;
}
static int reject_entry(const unsigned char *sha1, struct strbuf *base,
static int reject_entry(const struct object_id *oid, struct strbuf *base,
const char *filename, unsigned mode,
int stage, void *context)
{
......@@ -397,8 +397,8 @@ static void parse_treeish_arg(const char **argv,
unsigned int mode;
int err;
err = get_tree_entry(tree->object.oid.hash, prefix,
tree_oid.hash, &mode);
err = get_tree_entry(&tree->object.oid, prefix, &tree_oid,
&mode);
if (err || !S_ISDIR(mode))
die("current working directory is untracked");
......
......@@ -31,7 +31,7 @@ extern void init_tar_archiver(void);
extern void init_zip_archiver(void);
typedef int (*write_archive_entry_fn_t)(struct archiver_args *args,
const unsigned char *sha1,
const struct object_id *oid,
const char *path, size_t pathlen,
unsigned int mode);
......@@ -39,9 +39,9 @@ extern int write_archive_entries(struct archiver_args *args, write_archive_entry
extern int write_archive(int argc, const char **argv, const char *prefix, const char *name_hint, int remote);
const char *archive_format_from_filename(const char *filename);
extern void *sha1_file_to_archive(const struct archiver_args *args,
const char *path, const unsigned char *sha1,
unsigned int mode, enum object_type *type,
unsigned long *sizep);
extern void *object_file_to_archive(const struct archiver_args *args,
const char *path, const struct object_id *oid,
unsigned int mode, enum object_type *type,
unsigned long *sizep);
#endif /* ARCHIVE_H */
......@@ -132,7 +132,8 @@ static void show_list(const char *debug, int counted, int nr,
unsigned flags = commit->object.flags;
enum object_type type;
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;
int subject_len;
......
......@@ -80,8 +80,8 @@ static void verify_working_tree_path(struct commit *work_tree, const char *path)
struct object_id blob_oid;
unsigned mode;
if (!get_tree_entry(commit_oid->hash, path, blob_oid.hash, &mode) &&
sha1_object_info(blob_oid.hash, NULL) == OBJ_BLOB)
if (!get_tree_entry(commit_oid, path, &blob_oid, &mode) &&
oid_object_info(&blob_oid, NULL) == OBJ_BLOB)
return;
}
......@@ -297,8 +297,8 @@ static void fill_origin_blob(struct diff_options *opt,
textconv_object(o->path, o->mode, &o->blob_oid, 1, &file->ptr, &file_size))
;
else
file->ptr = read_sha1_file(o->blob_oid.hash, &type,
&file_size);
file->ptr = read_object_file(&o->blob_oid, &type,
&file_size);
file->size = file_size;
if (!file->ptr)
......@@ -502,11 +502,9 @@ static int fill_blob_sha1_and_mode(struct blame_origin *origin)
{
if (!is_null_oid(&origin->blob_oid))
return 0;
if (get_tree_entry(origin->commit->object.oid.hash,
origin->path,
origin->blob_oid.hash, &origin->mode))
if (get_tree_entry(&origin->commit->object.oid, origin->path, &origin->blob_oid, &origin->mode))
goto error_out;
if (sha1_object_info(origin->blob_oid.hash, NULL) != OBJ_BLOB)
if (oid_object_info(&origin->blob_oid, NULL) != OBJ_BLOB)
goto error_out;
return 0;
error_out:
......@@ -1831,8 +1829,8 @@ void setup_scoreboard(struct blame_scoreboard *sb, const char *path, struct blam
&sb->final_buf_size))
;
else
sb->final_buf = read_sha1_file(o->blob_oid.hash, &type,
&sb->final_buf_size);
sb->final_buf = read_object_file(&o->blob_oid, &type,
&sb->final_buf_size);
if (!sb->final_buf)
die(_("cannot read blob %s for path %s"),
......
......@@ -1550,7 +1550,7 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa
discard_cache();
read_cache_from(index_path);
if (write_index_as_tree(orig_tree.hash, &the_index, index_path, 0, NULL))
if (write_index_as_tree(&orig_tree, &the_index, index_path, 0, NULL))
return error(_("Repository lacks necessary blobs to fall back on 3-way merge."));
say(state, stdout, _("Using index info to reconstruct a base tree..."));
......@@ -1575,7 +1575,7 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa
return error(_("Did you hand edit your patch?\n"
"It does not apply to blobs recorded in its index."));
if (write_index_as_tree(their_tree.hash, &the_index, index_path, 0, NULL))
if (write_index_as_tree(&their_tree, &the_index, index_path, 0, NULL))
return error("could not write tree");
say(state, stdout, _("Falling back to patching base and 3-way merge..."));
......@@ -1626,7 +1626,7 @@ static void do_commit(const struct am_state *state)
if (run_hook_le(NULL, "pre-applypatch", NULL))
exit(1);
if (write_cache_as_tree(tree.hash, 0, NULL))
if (write_cache_as_tree(&tree, 0, NULL))
die(_("git write-tree failed to write a tree"));
if (!get_oid_commit("HEAD", &parent)) {
......@@ -2004,7 +2004,7 @@ static int clean_index(const struct object_id *head, const struct object_id *rem
if (fast_forward_to(head_tree, head_tree, 1))
return -1;
if (write_cache_as_tree(index.hash, 0, NULL))
if (write_cache_as_tree(&index, 0, NULL))
return -1;
index_tree = parse_tree_indirect(&index);
......
......@@ -499,7 +499,7 @@ static int read_ancestry(const char *graft_file)
static int update_auto_abbrev(int auto_abbrev, struct blame_origin *suspect)
{
const char *uniq = find_unique_abbrev(suspect->commit->object.oid.hash,
const char *uniq = find_unique_abbrev(&suspect->commit->object.oid,
auto_abbrev);
int len = strlen(uniq);
if (auto_abbrev < len)
......@@ -655,7 +655,7 @@ static int is_a_rev(const char *name)
if (get_oid(name, &oid))
return 0;
return OBJ_NONE < sha1_object_info(oid.hash, NULL);
return OBJ_NONE < oid_object_info(&oid, NULL);
}
int cmd_blame(int argc, const char **argv, const char *prefix)
......
......@@ -273,7 +273,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
bname.buf,
(flags & REF_ISBROKEN) ? "broken"
: (flags & REF_ISSYMREF) ? target
: find_unique_abbrev(oid.hash, DEFAULT_ABBREV));
: find_unique_abbrev(&oid, DEFAULT_ABBREV));
}
delete_branch_config(bname.buf);
......
......@@ -32,7 +32,7 @@ static int filter_object(const char *path, unsigned mode,
{
enum object_type type;
*buf = read_sha1_file(oid->hash, &type, size);
*buf = read_object_file(oid, &type, size);
if (!*buf)
return error(_("cannot read object %s '%s'"),
oid_to_hex(oid), path);
......@@ -77,7 +77,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
switch (opt) {
case 't':
oi.type_name = &sb;
if (sha1_object_info_extended(oid.hash, &oi, flags) < 0)
if (oid_object_info_extended(&oid, &oi, flags) < 0)
die("git cat-file: could not get object info");
if (sb.len) {
printf("%s\n", sb.buf);
......@@ -88,7 +88,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
case 's':
oi.sizep = &size;
if (sha1_object_info_extended(oid.hash, &oi, flags) < 0)
if (oid_object_info_extended(&oid, &oi, flags) < 0)
die("git cat-file: could not get object info");
printf("%lu\n", size);
return 0;
......@@ -116,7 +116,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
/* else fallthrough */
case 'p':
type = sha1_object_info(oid.hash, NULL);
type = oid_object_info(&oid, NULL);
if (type < 0)
die("Not a valid object name %s", obj_name);
......@@ -130,7 +130,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
if (type == OBJ_BLOB)
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)
die("Cannot read object %s", obj_name);
......@@ -140,8 +140,9 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
case 0:
if (type_from_string(exp_type) == OBJ_BLOB) {
struct object_id blob_oid;
if (sha1_object_info(oid.hash, NULL) == OBJ_TAG) {
char *buffer = read_sha1_file(oid.hash, &type, &size);
if (oid_object_info(&oid, NULL) == OBJ_TAG) {
char *buffer = read_object_file(&oid, &type,
&size);
const char *target;
if (!skip_prefix(buffer, "object ", &target) ||
get_oid_hex(target, &blob_oid))
......@@ -150,7 +151,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
} else
oidcpy(&blob_oid, &oid);
if (sha1_object_info(blob_oid.hash, NULL) == OBJ_BLOB)
if (oid_object_info(&blob_oid, NULL) == OBJ_BLOB)
return stream_blob_to_fd(1, &blob_oid, NULL, 0);
/*
* we attempted to dereference a tag to a blob
......@@ -159,7 +160,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
* fall-back to the usual case.
*/
}
buf = read_object_with_reference(oid.hash, exp_type, &size, NULL);
buf = read_object_with_reference(&oid, exp_type, &size, NULL);
break;
default:
......@@ -304,8 +305,9 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
enum object_type type;
if (!textconv_object(data->rest, 0100644, oid,
1, &contents, &size))
contents = read_sha1_file(oid->hash, &type,
&size);
contents = read_object_file(oid,
&type,
&size);
if (!contents)
die("could not convert '%s' %s",
oid_to_hex(oid), data->rest);
......@@ -321,7 +323,7 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
unsigned long size;
void *contents;
contents = read_sha1_file(oid->hash, &type, &size);
contents = read_object_file(oid, &type, &size);
if (!contents)
die("object %s disappeared", oid_to_hex(oid));
if (type != data->type)
......@@ -340,8 +342,8 @@ static void batch_object_write(const char *obj_name, struct batch_options *opt,
struct strbuf buf = STRBUF_INIT;
if (!data->skip_object_info &&
sha1_object_info_extended(data->oid.hash, &data->info,
OBJECT_INFO_LOOKUP_REPLACE) < 0) {
oid_object_info_extended(&data->oid, &data->info,
OBJECT_INFO_LOOKUP_REPLACE) < 0) {
printf("%s missing\n",
obj_name ? obj_name : oid_to_hex(&data->oid));
fflush(stdout);
......
......@@ -66,7 +66,7 @@ static int post_checkout_hook(struct commit *old_commit, struct commit *new_comm
}
static int update_some(const unsigned char *sha1, struct strbuf *base,
static int update_some(const struct object_id *oid, struct strbuf *base,
const char *pathname, unsigned mode, int stage, void *context)
{
int len;
......@@ -78,7 +78,7 @@ static int update_some(const unsigned char *sha1, struct strbuf *base,
len = base->len + strlen(pathname);
ce = xcalloc(1, cache_entry_size(len));
hashcpy(ce->oid.hash, sha1);
oidcpy(&ce->oid, oid);
memcpy(ce->name, base->buf, base->len);
memcpy(ce->name + base->len, pathname, len - base->len);
ce->ce_flags = create_ce_flags(0) | CE_UPDATE;
......@@ -405,10 +405,10 @@ static void describe_detached_head(const char *msg, struct commit *commit)
pp_commit_easy(CMIT_FMT_ONELINE, commit, &sb);
if (print_sha1_ellipsis()) {
fprintf(stderr, "%s %s... %s\n", msg,
find_unique_abbrev(commit->object.oid.hash, DEFAULT_ABBREV), sb.buf);
find_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV), sb.buf);
} else {
fprintf(stderr, "%s %s %s\n", msg,
find_unique_abbrev(commit->object.oid.hash, DEFAULT_ABBREV), sb.buf);
find_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV), sb.buf);
}
strbuf_release(&sb);
}
......@@ -720,7 +720,7 @@ static int add_pending_uninteresting_ref(const char *refname,
static void describe_one_orphan(struct strbuf *sb, struct commit *commit)
{
strbuf_addstr(sb, " ");
strbuf_add_unique_abbrev(sb, commit->object.oid.hash, DEFAULT_ABBREV);
strbuf_add_unique_abbrev(sb, &commit->object.oid, DEFAULT_ABBREV);
strbuf_addch(sb, ' ');
if (!parse_commit(commit))
pp_commit_easy(CMIT_FMT_ONELINE, commit, sb);
......@@ -778,7 +778,7 @@ static void suggest_reattach(struct commit *commit, struct rev_info *revs)
" git branch <new-branch-name> %s\n\n",
/* Give ngettext() the count */
lost),
find_unique_abbrev(commit->object.oid.hash, DEFAULT_ABBREV));
find_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV));
}
/*
......
......@@ -58,7 +58,7 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
usage(commit_tree_usage);
if (get_oid_commit(argv[i], &oid))
die("Not a valid object name %s", argv[i]);
assert_sha1_type(oid.hash, OBJ_COMMIT);
assert_oid_type(&oid, OBJ_COMMIT);
new_parent(lookup_commit(&oid), &parents);
continue;
}
......
......@@ -285,7 +285,7 @@ static void append_name(struct commit_name *n, struct strbuf *dst)
static void append_suffix(int depth, const struct object_id *oid, struct strbuf *dst)
{
strbuf_addf(dst, "-%d-g%s", depth, find_unique_abbrev(oid->hash, abbrev));
strbuf_addf(dst, "-%d-g%s", depth, find_unique_abbrev(oid, abbrev));
}
static void describe_commit(struct object_id *oid, struct strbuf *dst)
......@@ -383,7 +383,7 @@ static void describe_commit(struct object_id *oid, struct strbuf *dst)
if (!match_cnt) {
struct object_id *cmit_oid = &cmit->object.oid;
if (always) {
strbuf_add_unique_abbrev(dst, cmit_oid->hash, abbrev);
strbuf_add_unique_abbrev(dst, cmit_oid, abbrev);
if (suffix)
strbuf_addstr(dst, suffix);
return;
......@@ -502,7 +502,7 @@ static void describe(const char *arg, int last_one)
if (cmit)
describe_commit(&oid, &sb);
else if (sha1_object_info(oid.hash, NULL) == OBJ_BLOB)
else if (oid_object_info(&oid, NULL) == OBJ_BLOB)
describe_blob(oid, &sb);
else
die(_("%s is neither a commit nor blob"), arg);
......
......@@ -306,7 +306,7 @@ static char *get_symlink(const struct object_id *oid, const char *path)
} else {
enum object_type type;
unsigned long size;
data = read_sha1_file(oid->hash, &type, &size);
data = read_object_file(oid, &type, &size);
if (!data)
die(_("could not read object %s for symlink %s"),
oid_to_hex(oid), path);
......
......@@ -237,10 +237,10 @@ static void export_blob(const struct object_id *oid)
object = (struct object *)lookup_blob(oid);
eaten = 0;
} else {
buf = read_sha1_file(oid->hash, &type, &size);
buf = read_object_file(oid, &type, &size);
if (!buf)
die ("Could not read blob %s", oid_to_hex(oid));
if (check_sha1_signature(oid->hash, buf, size, type_name(type)) < 0)
if (check_object_signature(oid, buf, size, type_name(type)) < 0)
die("sha1 mismatch in blob %s", oid_to_hex(oid));
object = parse_object_buffer(oid, type, size, buf, &eaten);
}
......@@ -682,7 +682,7 @@ static void handle_tag(const char *name, struct tag *tag)
return;
}
buf = read_sha1_file(tag->object.oid.hash, &type, &size);
buf = read_object_file(&tag->object.oid, &type, &size);
if (!buf)
die ("Could not read tag %s", oid_to_hex(&tag->object.oid));
message = memmem(buf, size, "\n\n", 2);
......@@ -947,7 +947,7 @@ static void import_marks(char *input_file)
if (last_idnum < mark)
last_idnum = mark;
type = sha1_object_info(oid.hash, NULL);
type = oid_object_info(&oid, NULL);
if (type < 0)
die("object not found: %s", oid_to_hex(&oid));
......
......@@ -637,7 +637,7 @@ static int update_local_ref(struct ref *ref,
struct branch *current_branch = branch_get(NULL);
const char *pretty_ref = prettify_refname(ref->name);
type = sha1_object_info(ref->new_oid.hash, NULL);