object: convert parse_object* to take struct object_id

Make parse_object, parse_object_or_die, and parse_object_buffer take a
pointer to struct object_id.  Remove the temporary variables inserted
earlier, since they are no longer necessary.  Transform all of the
callers using the following semantic patch:

@@
expression E1;
@@
- parse_object(E1.hash)
+ parse_object(&E1)

@@
expression E1;
@@
- parse_object(E1->hash)
+ parse_object(E1)

@@
expression E1, E2;
@@
- parse_object_or_die(E1.hash, E2)
+ parse_object_or_die(&E1, E2)

@@
expression E1, E2;
@@
- parse_object_or_die(E1->hash, E2)
+ parse_object_or_die(E1, E2)

@@
expression E1, E2, E3, E4, E5;
@@
- parse_object_buffer(E1.hash, E2, E3, E4, E5)
+ parse_object_buffer(&E1, E2, E3, E4, E5)

@@
expression E1, E2, E3, E4, E5;
@@
- parse_object_buffer(E1->hash, E2, E3, E4, E5)
+ parse_object_buffer(E1, E2, E3, E4, E5)

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:38 +00:00 коммит произвёл Junio C Hamano
Родитель a9dbc17910
Коммит c251c83df2
38 изменённых файлов: 107 добавлений и 108 удалений

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

@ -67,7 +67,7 @@ static int diff_tree_stdin(char *line)
line[len-1] = 0;
if (parse_oid_hex(line, &oid, &p))
return -1;
obj = parse_object(oid.hash);
obj = parse_object(&oid);
if (!obj)
return -1;
if (obj->type == OBJ_COMMIT)

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

@ -395,7 +395,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
const char *name = entry->name;
int flags = (obj->flags & UNINTERESTING);
if (!obj->parsed)
obj = parse_object(obj->oid.hash);
obj = parse_object(&obj->oid);
obj = deref_tag(obj, NULL, 0);
if (!obj)
die(_("invalid object '%s' given."), name);

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

@ -240,7 +240,7 @@ static void export_blob(const struct object_id *oid)
die ("Could not read blob %s", oid_to_hex(oid));
if (check_sha1_signature(oid->hash, buf, size, typename(type)) < 0)
die("sha1 mismatch in blob %s", oid_to_hex(oid));
object = parse_object_buffer(oid->hash, type, size, buf, &eaten);
object = parse_object_buffer(oid, type, size, buf, &eaten);
}
if (!object)
@ -777,7 +777,7 @@ static struct commit *get_commit(struct rev_cmdline_entry *e, char *full_name)
/* handle nested tags */
while (tag && tag->object.type == OBJ_TAG) {
parse_object(tag->object.oid.hash);
parse_object(&tag->object.oid);
string_list_append(&extra_refs, full_name)->util = tag;
tag = (struct tag *)tag->tagged;
}

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

@ -341,7 +341,7 @@ static void shortlog(const char *name,
const struct object_id *oid = &origin_data->oid;
int limit = opts->shortlog_len;
branch = deref_tag(parse_object(oid->hash), oid_to_hex(oid), GIT_SHA1_HEXSZ);
branch = deref_tag(parse_object(oid), oid_to_hex(oid), GIT_SHA1_HEXSZ);
if (!branch || branch->type != OBJ_COMMIT)
return;
@ -559,7 +559,7 @@ static void find_merge_parents(struct merge_parents *result,
* "name" here and we do not want to contaminate its
* util field yet.
*/
obj = parse_object(oid.hash);
obj = parse_object(&oid);
parent = (struct commit *)peel_to_type(NULL, 0, obj, OBJ_COMMIT);
if (!parent)
continue;

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

@ -385,7 +385,7 @@ static int fsck_obj_buffer(const struct object_id *oid, enum object_type type,
* verify_packfile(), data_valid variable for details.
*/
struct object *obj;
obj = parse_object_buffer(oid->hash, type, size, buffer, eaten);
obj = parse_object_buffer(oid, type, size, buffer, eaten);
if (!obj) {
errors_found |= ERROR_OBJECT;
return error("%s: object corrupt or missing", oid_to_hex(oid));
@ -444,7 +444,7 @@ static int fsck_handle_ref(const char *refname, const struct object_id *oid,
{
struct object *obj;
obj = parse_object(oid->hash);
obj = parse_object(oid);
if (!obj) {
error("%s: invalid sha1 pointer %s", refname, oid_to_hex(oid));
errors_found |= ERROR_REACHABLE;
@ -506,7 +506,7 @@ static struct object *parse_loose_object(const struct object_id *oid,
if (!contents && type != OBJ_BLOB)
die("BUG: read_loose_object streamed a non-blob");
obj = parse_object_buffer(oid->hash, type, size, contents, &eaten);
obj = parse_object_buffer(oid, type, size, contents, &eaten);
if (!eaten)
free(contents);
@ -599,7 +599,7 @@ static int fsck_cache_tree(struct cache_tree *it)
fprintf(stderr, "Checking cache tree\n");
if (0 <= it->entry_count) {
struct object *obj = parse_object(it->oid.hash);
struct object *obj = parse_object(&it->oid);
if (!obj) {
error("%s: invalid sha1 pointer in cache-tree",
oid_to_hex(&it->oid));

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

@ -1196,7 +1196,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
break;
}
object = parse_object_or_die(oid.hash, arg);
object = parse_object_or_die(&oid, arg);
if (!seen_dashdash)
verify_non_filename(prefix, arg);
add_object_array_with_path(object, arg, &list, oc.mode, oc.path);

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

@ -845,7 +845,8 @@ 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(oid->hash, type, size, buf, &eaten);
obj = parse_object_buffer(oid, type, size, buf,
&eaten);
if (!obj)
die(_("invalid %s"), typename(type));
if (do_fsck_object &&

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

@ -596,7 +596,7 @@ int cmd_show(int argc, const char **argv, const char *prefix)
rev.shown_one = 1;
if (ret)
break;
o = parse_object(t->tagged->oid.hash);
o = parse_object(&t->tagged->oid);
if (!o)
ret = error(_("Could not read object %s"),
oid_to_hex(&t->tagged->oid));

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

@ -142,7 +142,7 @@ static int tipcmp(const void *a_, const void *b_)
static int name_ref(const char *path, const struct object_id *oid, int flags, void *cb_data)
{
struct object *o = parse_object(oid->hash);
struct object *o = parse_object(oid);
struct name_ref_data *data = cb_data;
int can_abbreviate_output = data->tags_only && data->name_only;
int deref = 0;
@ -200,7 +200,7 @@ static int name_ref(const char *path, const struct object_id *oid, int flags, vo
struct tag *t = (struct tag *) o;
if (!t->tagged)
break; /* broken repository */
o = parse_object(t->tagged->oid.hash);
o = parse_object(&t->tagged->oid);
deref = 1;
taggerdate = t->date;
}
@ -385,7 +385,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)
}
commit = NULL;
object = parse_object(oid.hash);
object = parse_object(&oid);
if (object) {
struct object *peeled = deref_tag(object, *argv, 0);
if (peeled && peeled->type == OBJ_COMMIT)

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

@ -127,7 +127,8 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
const char *name = *argv++;
if (!get_oid(name, &oid)) {
struct object *object = parse_object_or_die(oid.hash, name);
struct object *object = parse_object_or_die(&oid,
name);
add_pending_object(&revs, object, "");
}
else

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

@ -1058,8 +1058,8 @@ static const char *update(struct command *cmd, struct shallow_info *si)
struct object *old_object, *new_object;
struct commit *old_commit, *new_commit;
old_object = parse_object(old_oid->hash);
new_object = parse_object(new_oid->hash);
old_object = parse_object(old_oid);
new_object = parse_object(new_oid);
if (!old_object || !new_object ||
old_object->type != OBJ_COMMIT ||
@ -1082,7 +1082,7 @@ static const char *update(struct command *cmd, struct shallow_info *si)
if (is_null_oid(new_oid)) {
struct strbuf err = STRBUF_INIT;
if (!parse_object(old_oid->hash)) {
if (!parse_object(old_oid)) {
old_oid = NULL;
if (ref_exists(name)) {
rp_warning("Allowing deletion of corrupt ref.");

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

@ -126,7 +126,7 @@ static int commit_is_complete(struct commit *commit)
struct commit_list *parent;
c = (struct commit *)study.objects[--study.nr].item;
if (!c->object.parsed && !parse_object(c->object.oid.hash))
if (!c->object.parsed && !parse_object(&c->object.oid))
c->object.flags |= INCOMPLETE;
if (c->object.flags & INCOMPLETE) {

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

@ -181,7 +181,7 @@ static void finish_object(struct object *obj, const char *name, void *cb_data)
if (obj->type == OBJ_BLOB && !has_object_file(&obj->oid))
die("missing blob object '%s'", oid_to_hex(&obj->oid));
if (info->revs->verify_objects && !obj->parsed && obj->type != OBJ_COMMIT)
parse_object(obj->oid.hash);
parse_object(&obj->oid);
}
static void show_object(struct object *obj, const char *name, void *cb_data)

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

@ -260,7 +260,8 @@ static void write_object(unsigned nr, enum object_type type,
int eaten;
hash_sha1_file(buf, size, typename(type), obj_list[nr].oid.hash);
added_object(nr, type, buf, size);
obj = parse_object_buffer(obj_list[nr].oid.hash, type, size, buf, &eaten);
obj = parse_object_buffer(&obj_list[nr].oid, type, size, buf,
&eaten);
if (!obj)
die("invalid %s", typename(type));
add_object_buffer(obj, buf, size);

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

@ -142,7 +142,7 @@ int verify_bundle(struct bundle_header *header, int verbose)
init_revisions(&revs, NULL);
for (i = 0; i < p->nr; i++) {
struct ref_list_entry *e = p->list + i;
struct object *o = parse_object(e->oid.hash);
struct object *o = parse_object(&e->oid);
if (o) {
o->flags |= PREREQ_MARK;
add_pending_object(&revs, o, e->name);
@ -290,12 +290,14 @@ static int compute_and_write_prerequisites(int bundle_fd,
if (buf.len > 0 && buf.buf[0] == '-') {
write_or_die(bundle_fd, buf.buf, buf.len);
if (!get_oid_hex(buf.buf + 1, &oid)) {
struct object *object = parse_object_or_die(oid.hash, buf.buf);
struct object *object = parse_object_or_die(&oid,
buf.buf);
object->flags |= UNINTERESTING;
add_pending_object(revs, object, buf.buf);
}
} else if (!get_oid_hex(buf.buf, &oid)) {
struct object *object = parse_object_or_die(oid.hash, buf.buf);
struct object *object = parse_object_or_die(&oid,
buf.buf);
object->flags |= SHOWN;
}
}
@ -379,7 +381,7 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs)
* end up triggering "empty bundle"
* error.
*/
obj = parse_object_or_die(oid.hash, e->name);
obj = parse_object_or_die(&oid, e->name);
obj->flags |= SHOWN;
add_pending_object(revs, obj, e->name);
}

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

@ -21,7 +21,7 @@ const char *commit_type = "commit";
struct commit *lookup_commit_reference_gently(const struct object_id *oid,
int quiet)
{
struct object *obj = deref_tag(parse_object(oid->hash), NULL, 0);
struct object *obj = deref_tag(parse_object(oid), NULL, 0);
if (!obj)
return NULL;
@ -1589,7 +1589,7 @@ struct commit *get_merge_parent(const char *name)
struct object_id oid;
if (get_sha1(name, oid.hash))
return NULL;
obj = parse_object(oid.hash);
obj = parse_object(&oid);
commit = (struct commit *)peel_to_type(name, 0, obj, OBJ_COMMIT);
if (commit && !commit->util)
set_merge_remote_desc(commit, name, obj);

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

@ -78,7 +78,7 @@ static void cache_one_alternate(const char *refname,
void *vcache)
{
struct alternate_object_cache *cache = vcache;
struct object *obj = parse_object(oid->hash);
struct object *obj = parse_object(oid);
if (!obj || (obj->flags & ALTERNATE))
return;
@ -120,7 +120,7 @@ static void rev_list_push(struct commit *commit, int mark)
static int rev_list_insert_ref(const char *refname, const struct object_id *oid)
{
struct object *o = deref_tag(parse_object(oid->hash), refname, 0);
struct object *o = deref_tag(parse_object(oid), refname, 0);
if (o && o->type == OBJ_COMMIT)
rev_list_push((struct commit *)o, SEEN);
@ -137,7 +137,7 @@ static int rev_list_insert_ref_oid(const char *refname, const struct object_id *
static int clear_marks(const char *refname, const struct object_id *oid,
int flag, void *cb_data)
{
struct object *o = deref_tag(parse_object(oid->hash), refname, 0);
struct object *o = deref_tag(parse_object(oid), refname, 0);
if (o && o->type == OBJ_COMMIT)
clear_commit_marks((struct commit *)o,
@ -426,7 +426,7 @@ static int find_common(struct fetch_pack_args *args,
if (!lookup_object(oid.hash))
die(_("object not found: %s"), line);
/* make sure that it is parsed as shallow */
if (!parse_object(oid.hash))
if (!parse_object(&oid))
die(_("error in object: %s"), line);
if (unregister_shallow(&oid))
die(_("no shallow found: %s"), line);
@ -557,14 +557,14 @@ static struct commit_list *complete;
static int mark_complete(const struct object_id *oid)
{
struct object *o = parse_object(oid->hash);
struct object *o = parse_object(oid);
while (o && o->type == OBJ_TAG) {
struct tag *t = (struct tag *) o;
if (!t->tagged)
break; /* broken repository */
o->flags |= COMPLETE;
o = parse_object(t->tagged->oid.hash);
o = parse_object(&t->tagged->oid);
}
if (o && o->type == OBJ_COMMIT) {
struct commit *commit = (struct commit *)o;
@ -681,7 +681,7 @@ static int everything_local(struct fetch_pack_args *args,
if (!has_object_file(&ref->old_oid))
continue;
o = parse_object(ref->old_oid.hash);
o = parse_object(&ref->old_oid);
if (!o)
continue;

2
fsck.c
Просмотреть файл

@ -461,7 +461,7 @@ int fsck_walk(struct object *obj, void *data, struct fsck_options *options)
return -1;
if (obj->type == OBJ_NONE)
parse_object(obj->oid.hash);
parse_object(&obj->oid);
switch (obj->type) {
case OBJ_BLOB:

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

@ -431,7 +431,7 @@ static int show_text_ref(const char *name, const struct object_id *oid,
{
const char *name_nons = strip_namespace(name);
struct strbuf *buf = cb_data;
struct object *o = parse_object(oid->hash);
struct object *o = parse_object(oid);
if (!o)
return 0;

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

@ -724,7 +724,7 @@ static void one_remote_object(const struct object_id *oid)
obj = lookup_object(oid->hash);
if (!obj)
obj = parse_object(oid->hash);
obj = parse_object(oid);
/* Ignore remote objects that don't exist locally */
if (!obj)
@ -1462,7 +1462,7 @@ static void add_remote_info_ref(struct remote_ls_ctx *ls)
return;
}
o = parse_object(ref->old_oid.hash);
o = parse_object(&ref->old_oid);
if (!o) {
fprintf(stderr,
"Unable to parse object %s for remote ref %s\n",

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

@ -105,13 +105,13 @@ static int add_ref_decoration(const char *refname, const struct object_id *oid,
warning("invalid replace ref %s", refname);
return 0;
}
obj = parse_object(original_oid.hash);
obj = parse_object(&original_oid);
if (obj)
add_name_decoration(DECORATION_GRAFTED, "replaced", obj);
return 0;
}
obj = parse_object(oid->hash);
obj = parse_object(oid);
if (!obj)
return 0;
@ -132,7 +132,7 @@ static int add_ref_decoration(const char *refname, const struct object_id *oid,
if (!obj)
break;
if (!obj->parsed)
parse_object(obj->oid.hash);
parse_object(&obj->oid);
add_name_decoration(DECORATION_REF_TAG, refname, obj);
}
return 0;

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

@ -2103,7 +2103,7 @@ static struct commit *get_ref(const struct object_id *oid, const char *name)
{
struct object *object;
object = deref_tag(parse_object(oid->hash), name, strlen(name));
object = deref_tag(parse_object(oid), name, strlen(name));
if (!object)
return NULL;
if (object->type == OBJ_TREE)

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

@ -180,24 +180,21 @@ struct object *lookup_unknown_object(const unsigned char *sha1)
return obj;
}
struct object *parse_object_buffer(const unsigned char *sha1, enum object_type type, unsigned long size, void *buffer, int *eaten_p)
struct object *parse_object_buffer(const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p)
{
struct object_id oid;
struct object *obj;
*eaten_p = 0;
hashcpy(oid.hash, sha1);
obj = NULL;
if (type == OBJ_BLOB) {
struct blob *blob = lookup_blob(&oid);
struct blob *blob = lookup_blob(oid);
if (blob) {
if (parse_blob_buffer(blob, buffer, size))
return NULL;
obj = &blob->object;
}
} else if (type == OBJ_TREE) {
struct tree *tree = lookup_tree(&oid);
struct tree *tree = lookup_tree(oid);
if (tree) {
obj = &tree->object;
if (!tree->buffer)
@ -209,7 +206,7 @@ struct object *parse_object_buffer(const unsigned char *sha1, enum object_type t
}
}
} else if (type == OBJ_COMMIT) {
struct commit *commit = lookup_commit(&oid);
struct commit *commit = lookup_commit(oid);
if (commit) {
if (parse_commit_buffer(commit, buffer, size))
return NULL;
@ -220,57 +217,54 @@ struct object *parse_object_buffer(const unsigned char *sha1, enum object_type t
obj = &commit->object;
}
} else if (type == OBJ_TAG) {
struct tag *tag = lookup_tag(&oid);
struct tag *tag = lookup_tag(oid);
if (tag) {
if (parse_tag_buffer(tag, buffer, size))
return NULL;
obj = &tag->object;
}
} else {
warning("object %s has unknown type id %d", sha1_to_hex(sha1), type);
warning("object %s has unknown type id %d", oid_to_hex(oid), type);
obj = NULL;
}
return obj;
}
struct object *parse_object_or_die(const unsigned char *sha1,
struct object *parse_object_or_die(const struct object_id *oid,
const char *name)
{
struct object *o = parse_object(sha1);
struct object *o = parse_object(oid);
if (o)
return o;
die(_("unable to parse object: %s"), name ? name : sha1_to_hex(sha1));
die(_("unable to parse object: %s"), name ? name : oid_to_hex(oid));
}
struct object *parse_object(const unsigned char *sha1)
struct object *parse_object(const struct object_id *oid)
{
unsigned long size;
enum object_type type;
int eaten;
const unsigned char *repl = lookup_replace_object(sha1);
const unsigned char *repl = lookup_replace_object(oid->hash);
void *buffer;
struct object *obj;
struct object_id oid;
hashcpy(oid.hash, sha1);
obj = lookup_object(oid.hash);
obj = lookup_object(oid->hash);
if (obj && obj->parsed)
return obj;
if ((obj && obj->type == OBJ_BLOB) ||
(!obj && has_sha1_file(sha1) &&
sha1_object_info(sha1, NULL) == OBJ_BLOB)) {
(!obj && has_object_file(oid) &&
sha1_object_info(oid->hash, NULL) == OBJ_BLOB)) {
if (check_sha1_signature(repl, NULL, 0, NULL) < 0) {
error("sha1 mismatch %s", sha1_to_hex(repl));
error("sha1 mismatch %s", oid_to_hex(oid));
return NULL;
}
parse_blob_buffer(lookup_blob(&oid), NULL, 0);
return lookup_object(sha1);
parse_blob_buffer(lookup_blob(oid), NULL, 0);
return lookup_object(oid->hash);
}
buffer = read_sha1_file(sha1, &type, &size);
buffer = read_sha1_file(oid->hash, &type, &size);
if (buffer) {
if (check_sha1_signature(repl, buffer, size, typename(type)) < 0) {
free(buffer);
@ -278,7 +272,7 @@ struct object *parse_object(const unsigned char *sha1)
return NULL;
}
obj = parse_object_buffer(sha1, type, size, buffer, &eaten);
obj = parse_object_buffer(oid, type, size, buffer, &eaten);
if (!eaten)
free(buffer);
return obj;

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

@ -89,20 +89,20 @@ void *object_as_type(struct object *obj, enum object_type type, int quiet);
*
* Returns NULL if the object is missing or corrupt.
*/
struct object *parse_object(const unsigned char *sha1);
struct object *parse_object(const struct object_id *oid);
/*
* Like parse_object, but will die() instead of returning NULL. If the
* "name" parameter is not NULL, it is included in the error message
* (otherwise, the sha1 hex is given).
* (otherwise, the hex object ID is given).
*/
struct object *parse_object_or_die(const unsigned char *sha1, const char *name);
struct object *parse_object_or_die(const struct object_id *oid, const char *name);
/* Given the result of read_sha1_file(), returns the object after
* parsing it. eaten_p indicates if the object has a borrowed copy
* of buffer and the caller should not free() it.
*/
struct object *parse_object_buffer(const unsigned char *sha1, enum object_type type, unsigned long size, void *buffer, int *eaten_p);
struct object *parse_object_buffer(const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p);
/** Returns the object, with potentially excess memory allocated. **/
struct object *lookup_unknown_object(const unsigned char *sha1);

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

@ -673,7 +673,7 @@ int prepare_bitmap_walk(struct rev_info *revs)
struct object *object = pending_e[i].item;
if (object->type == OBJ_NONE)
parse_object_or_die(object->oid.hash, NULL);
parse_object_or_die(&object->oid, NULL);
while (object->type == OBJ_TAG) {
struct tag *tag = (struct tag *) object;
@ -685,7 +685,7 @@ int prepare_bitmap_walk(struct rev_info *revs)
if (!tag->tagged)
die("bad tag");
object = parse_object_or_die(tag->tagged->oid.hash, NULL);
object = parse_object_or_die(&tag->tagged->oid, NULL);
}
if (object->flags & UNINTERESTING)

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

@ -1137,7 +1137,7 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */
/* these depend on the commit */
if (!commit->object.parsed)
parse_object(commit->object.oid.hash);
parse_object(&commit->object.oid);
switch (placeholder[0]) {
case 'H': /* commit hash */

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

@ -33,7 +33,7 @@ static int add_one_ref(const char *path, const struct object_id *oid,
return 0;
}
object = parse_object_or_die(oid->hash, path);
object = parse_object_or_die(oid, path);
add_pending_object(revs, object, "");
return 0;
@ -82,7 +82,7 @@ static void add_recent_object(const struct object_id *oid,
switch (type) {
case OBJ_TAG:
case OBJ_COMMIT:
obj = parse_object_or_die(oid->hash, NULL);
obj = parse_object_or_die(oid, NULL);
break;
case OBJ_TREE:
obj = (struct object *)lookup_tree(oid);

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

@ -683,7 +683,7 @@ static void *get_obj(const struct object_id *oid, struct object **obj, unsigned
void *buf = read_sha1_file(oid->hash, &type, sz);
if (buf)
*obj = parse_object_buffer(oid->hash, type, *sz, buf, eaten);
*obj = parse_object_buffer(oid, type, *sz, buf, eaten);
else
*obj = NULL;
return buf;
@ -1687,7 +1687,7 @@ static const struct object_id *match_points_at(struct oid_array *points_at,
if (oid_array_lookup(points_at, oid) >= 0)
return oid;
obj = parse_object(oid->hash);
obj = parse_object(oid);
if (!obj)
die(_("malformed object at '%s'"), refname);
if (obj->type == OBJ_TAG)

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

@ -238,13 +238,13 @@ void fake_reflog_parent(struct reflog_walk_info *info, struct commit *commit)
do {
reflog = &commit_reflog->reflogs->items[commit_reflog->recno];
commit_reflog->recno--;
logobj = parse_object(reflog->ooid.hash);
logobj = parse_object(&reflog->ooid);
} while (commit_reflog->recno && (logobj && logobj->type != OBJ_COMMIT));
if (!logobj && commit_reflog->recno >= 0 && is_null_oid(&reflog->ooid)) {
/* a root commit, but there are still more entries to show */
reflog = &commit_reflog->reflogs->items[commit_reflog->recno];
logobj = parse_object(reflog->noid.hash);
logobj = parse_object(&reflog->noid);
}
if (!logobj || logobj->type != OBJ_COMMIT) {

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

@ -2057,7 +2057,7 @@ static int write_ref_to_lockfile(struct ref_lock *lock,
struct object *o;
int fd;
o = parse_object(oid->hash);
o = parse_object(oid);
if (!o) {
strbuf_addf(err,
"trying to write ref '%s' with nonexistent object %s",

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

@ -1954,12 +1954,12 @@ int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid)
* Both new and old must be commit-ish and new is descendant of
* old. Otherwise we require --force.
*/
o = deref_tag(parse_object(old_oid->hash), NULL, 0);
o = deref_tag(parse_object(old_oid), NULL, 0);
if (!o || o->type != OBJ_COMMIT)
return 0;
old = (struct commit *) o;
o = deref_tag(parse_object(new_oid->hash), NULL, 0);
o = deref_tag(parse_object(new_oid), NULL, 0);
if (!o || o->type != OBJ_COMMIT)
return 0;
new = (struct commit *) o;

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

@ -181,7 +181,7 @@ void add_head_to_pending(struct rev_info *revs)
struct object *obj;
if (get_oid("HEAD", &oid))
return;
obj = parse_object(oid.hash);
obj = parse_object(&oid);
if (!obj)
return;
add_pending_object(revs, obj, "HEAD");
@ -193,7 +193,7 @@ static struct object *get_reference(struct rev_info *revs, const char *name,
{
struct object *object;
object = parse_object(oid->hash);
object = parse_object(oid);
if (!object) {
if (revs->ignore_missing)
return object;
@ -228,7 +228,7 @@ static struct commit *handle_commit(struct rev_info *revs,
add_pending_object(revs, object, tag->tag);
if (!tag->tagged)
die("bad tag");
object = parse_object(tag->tagged->oid.hash);
object = parse_object(&tag->tagged->oid);
if (!object) {
if (flags & UNINTERESTING)
return NULL;
@ -1200,7 +1200,7 @@ static void handle_one_reflog_commit(struct object_id *oid, void *cb_data)
{
struct all_refs_cb *cb = cb_data;
if (!is_null_oid(oid)) {
struct object *o = parse_object(oid->hash);
struct object *o = parse_object(oid);
if (o) {
o->flags |= cb->all_flags;
/* ??? CMDLINEFLAGS ??? */
@ -1479,8 +1479,8 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi
verify_non_filename(revs->prefix, arg);
}
a_obj = parse_object(from_oid.hash);
b_obj = parse_object(oid.hash);
a_obj = parse_object(&from_oid);
b_obj = parse_object(&oid);
if (!a_obj || !b_obj) {
missing:
if (revs->ignore_missing)

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

@ -53,7 +53,7 @@ static int add_info_ref(const char *path, const struct object_id *oid,
int flag, void *cb_data)
{
FILE *fp = cb_data;
struct object *o = parse_object(oid->hash);
struct object *o = parse_object(oid);
if (!o)
return -1;

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

@ -241,7 +241,7 @@ static int disambiguate_committish_only(const struct object_id *oid, void *cb_da
return 0;
/* We need to do this the hard way... */
obj = deref_tag(parse_object(oid->hash), NULL, 0);
obj = deref_tag(parse_object(oid), NULL, 0);
if (obj && obj->type == OBJ_COMMIT)
return 1;
return 0;
@ -265,7 +265,7 @@ static int disambiguate_treeish_only(const struct object_id *oid, void *cb_data_
return 0;
/* We need to do this the hard way... */
obj = deref_tag(parse_object(oid->hash), NULL, 0);
obj = deref_tag(parse_object(oid), NULL, 0);
if (obj && (obj->type == OBJ_TREE || obj->type == OBJ_COMMIT))
return 1;
return 0;
@ -776,7 +776,7 @@ struct object *peel_to_type(const char *name, int namelen,
if (name && !namelen)
namelen = strlen(name);
while (1) {
if (!o || (!o->parsed && !parse_object(o->oid.hash)))
if (!o || (!o->parsed && !parse_object(&o->oid)))
return NULL;
if (expected_type == OBJ_ANY || o->type == expected_type)
return o;
@ -849,12 +849,12 @@ static int peel_onion(const char *name, int len, unsigned char *sha1,
if (get_sha1_1(name, sp - name - 2, outer.hash, lookup_flags))
return -1;
o = parse_object(outer.hash);
o = parse_object(&outer);
if (!o)
return -1;
if (!expected_type) {
o = deref_tag(o, name, sp - name - 2);
if (!o || (!o->parsed && !parse_object(o->oid.hash)))
if (!o || (!o->parsed && !parse_object(&o->oid)))
return -1;
hashcpy(sha1, o->oid.hash);
return 0;
@ -981,7 +981,7 @@ static int handle_one_ref(const char *path, const struct object_id *oid,
int flag, void *cb_data)
{
struct commit_list **list = cb_data;
struct object *object = parse_object(oid->hash);
struct object *object = parse_object(oid);
if (!object)
return 0;
if (object->type == OBJ_TAG) {
@ -1027,7 +1027,7 @@ static int get_sha1_oneline(const char *prefix, unsigned char *sha1,
int matches;
commit = pop_most_recent_commit(&list, ONELINE_SEEN);
if (!parse_object(commit->object.oid.hash))
if (!parse_object(&commit->object.oid))
continue;
buf = get_commit_buffer(commit, NULL);
p = strstr(buf, "\n\n");

4
tag.c
Просмотреть файл

@ -66,7 +66,7 @@ struct object *deref_tag(struct object *o, const char *warn, int warnlen)
{
while (o && o->type == OBJ_TAG)
if (((struct tag *)o)->tagged)
o = parse_object(((struct tag *)o)->tagged->oid.hash);
o = parse_object(&((struct tag *)o)->tagged->oid);
else
o = NULL;
if (!o && warn) {
@ -80,7 +80,7 @@ struct object *deref_tag(struct object *o, const char *warn, int warnlen)
struct object *deref_tag_noverify(struct object *o)
{
while (o && o->type == OBJ_TAG) {
o = parse_object(o->oid.hash);
o = parse_object(&o->oid);
if (o && o->type == OBJ_TAG && ((struct tag *)o)->tagged)
o = ((struct tag *)o)->tagged;
else

4
tree.c
Просмотреть файл

@ -234,7 +234,7 @@ void free_tree_buffer(struct tree *tree)
struct tree *parse_tree_indirect(const struct object_id *oid)
{
struct object *obj = parse_object(oid->hash);
struct object *obj = parse_object(oid);
do {
if (!obj)
return NULL;
@ -247,6 +247,6 @@ struct tree *parse_tree_indirect(const struct object_id *oid)
else
return NULL;
if (!obj->parsed)
parse_object(obj->oid.hash);
parse_object(&obj->oid);
} while (1);
}

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

@ -296,7 +296,7 @@ static int got_oid(const char *hex, struct object_id *oid)
if (!has_object_file(oid))
return -1;
o = parse_object(oid->hash);
o = parse_object(oid);
if (!o)
die("oops (%s)", oid_to_hex(oid));
if (o->type == OBJ_COMMIT) {
@ -334,7 +334,7 @@ static int reachable(struct commit *want)
break;
}
if (!commit->object.parsed)
parse_object(commit->object.oid.hash);
parse_object(&commit->object.oid);
if (commit->object.flags & REACHABLE)
continue;
commit->object.flags |= REACHABLE;
@ -755,7 +755,7 @@ static void receive_needs(void)
struct object *object;
if (get_oid_hex(arg, &oid))
die("invalid shallow line: %s", line);
object = parse_object(oid.hash);
object = parse_object(&oid);
if (!object)
continue;
if (object->type != OBJ_COMMIT)
@ -821,7 +821,7 @@ static void receive_needs(void)
if (parse_feature_request(features, "include-tag"))
use_include_tag = 1;
o = parse_object(oid_buf.hash);
o = parse_object(&oid_buf);
if (!o) {
packet_write_fmt(1,
"ERR upload-pack: not our ref %s",

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

@ -180,7 +180,7 @@ static int loop(struct walker *walker)
}
}
if (!obj->type)
parse_object(obj->oid.hash);
parse_object(&obj->oid);
if (process_object(walker, obj))
return -1;
}