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>
38 files changed:
raw | patch | inline | side by side (parent: a9dbc17 )
line[len-1] = 0;
if (parse_oid_hex(line, &oid, &p))
return -1;
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)
if (!obj)
return -1;
if (obj->type == OBJ_COMMIT)
const char *name = entry->name;
int flags = (obj->flags & UNINTERESTING);
if (!obj->parsed)
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);
obj = deref_tag(obj, NULL, 0);
if (!obj)
die(_("invalid object '%s' given."), name);
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));
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);
/* handle nested tags */
while (tag && tag->object.type == OBJ_TAG) {
/* 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;
}
string_list_append(&extra_refs, full_name)->util = tag;
tag = (struct tag *)tag->tagged;
}
const struct object_id *oid = &origin_data->oid;
int limit = opts->shortlog_len;
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;
if (!branch || branch->type != OBJ_COMMIT)
return;
* "name" here and we do not want to contaminate its
* util field yet.
*/
* "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;
parent = (struct commit *)peel_to_type(NULL, 0, obj, OBJ_COMMIT);
if (!parent)
continue;
* verify_packfile(), data_valid variable for details.
*/
struct object *obj;
* 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));
if (!obj) {
errors_found |= ERROR_OBJECT;
return error("%s: object corrupt or missing", oid_to_hex(oid));
- 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;
if (!obj) {
error("%s: invalid sha1 pointer %s", refname, oid_to_hex(oid));
errors_found |= ERROR_REACHABLE;
if (!contents && type != OBJ_BLOB)
die("BUG: read_loose_object streamed a non-blob");
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);
if (!eaten)
free(contents);
fprintf(stderr, "Checking cache tree\n");
if (0 <= it->entry_count) {
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));
if (!obj) {
error("%s: invalid sha1 pointer in cache-tree",
oid_to_hex(&it->oid));
- 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);
if (!seen_dashdash)
verify_non_filename(prefix, arg);
add_object_array_with_path(object, arg, &list, oc.mode, oc.path);
* we do not need to free the memory here, as the
* buf is deleted by the caller.
*/
* 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 &&
if (!obj)
die(_("invalid %s"), typename(type));
if (do_fsck_object &&
rev.shown_one = 1;
if (ret)
break;
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));
if (!o)
ret = error(_("Could not read object %s"),
oid_to_hex(&t->tagged->oid));
static int name_ref(const char *path, const struct object_id *oid, int flags, void *cb_data)
{
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;
struct name_ref_data *data = cb_data;
int can_abbreviate_output = data->tags_only && data->name_only;
int deref = 0;
struct tag *t = (struct tag *) o;
if (!t->tagged)
break; /* broken repository */
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;
}
deref = 1;
taggerdate = t->date;
}
- 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)
if (object) {
struct object *peeled = deref_tag(object, *argv, 0);
if (peeled && peeled->type == OBJ_COMMIT)
const char *name = *argv++;
if (!get_oid(name, &oid)) {
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
add_pending_object(&revs, object, "");
}
else
struct object *old_object, *new_object;
struct commit *old_commit, *new_commit;
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 ||
if (!old_object || !new_object ||
old_object->type != OBJ_COMMIT ||
if (is_null_oid(new_oid)) {
struct strbuf err = STRBUF_INIT;
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.");
old_oid = NULL;
if (ref_exists(name)) {
rp_warning("Allowing deletion of corrupt ref.");
struct commit_list *parent;
c = (struct commit *)study.objects[--study.nr].item;
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) {
c->object.flags |= INCOMPLETE;
if (c->object.flags & INCOMPLETE) {
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)
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)
}
static void show_object(struct object *obj, const char *name, void *cb_data)
int eaten;
hash_sha1_file(buf, size, typename(type), obj_list[nr].oid.hash);
added_object(nr, type, buf, size);
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);
if (!obj)
die("invalid %s", typename(type));
add_object_buffer(obj, buf, size);
init_revisions(&revs, NULL);
for (i = 0; i < p->nr; i++) {
struct ref_list_entry *e = p->list + i;
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);
if (o) {
o->flags |= PREREQ_MARK;
add_pending_object(&revs, o, e->name);
if (buf.len > 0 && buf.buf[0] == '-') {
write_or_die(bundle_fd, buf.buf, buf.len);
if (!get_oid_hex(buf.buf + 1, &oid)) {
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)) {
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;
}
}
object->flags |= SHOWN;
}
}
* end up triggering "empty bundle"
* error.
*/
* 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);
}
obj->flags |= SHOWN;
add_pending_object(revs, obj, e->name);
}
struct commit *lookup_commit_reference_gently(const struct object_id *oid,
int quiet)
{
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);
struct object_id oid;
if (get_sha1(name, oid.hash))
return NULL;
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);
commit = (struct commit *)peel_to_type(name, 0, obj, OBJ_COMMIT);
if (commit && !commit->util)
set_merge_remote_desc(commit, name, obj);
void *vcache)
{
struct alternate_object_cache *cache = vcache;
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;
if (!obj || (obj->flags & ALTERNATE))
return;
static int rev_list_insert_ref(const char *refname, const struct object_id *oid)
{
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);
if (o && o->type == OBJ_COMMIT)
rev_list_push((struct commit *)o, SEEN);
static int clear_marks(const char *refname, const struct object_id *oid,
int flag, void *cb_data)
{
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,
if (o && o->type == OBJ_COMMIT)
clear_commit_marks((struct commit *)o,
if (!lookup_object(oid.hash))
die(_("object not found: %s"), line);
/* make sure that it is parsed as shallow */
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);
die(_("error in object: %s"), line);
if (unregister_shallow(&oid))
die(_("no shallow found: %s"), line);
static int mark_complete(const struct object_id *oid)
{
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;
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;
}
if (o && o->type == OBJ_COMMIT) {
struct commit *commit = (struct commit *)o;
if (!has_object_file(&ref->old_oid))
continue;
if (!has_object_file(&ref->old_oid))
continue;
- o = parse_object(ref->old_oid.hash );
+ o = parse_object(&ref->old_oid );
return -1;
if (obj->type == OBJ_NONE)
return -1;
if (obj->type == OBJ_NONE)
- parse_object(obj->oid.hash );
+ parse_object(&obj->oid );
switch (obj->type) {
case OBJ_BLOB:
switch (obj->type) {
case OBJ_BLOB:
{
const char *name_nons = strip_namespace(name);
struct strbuf *buf = cb_data;
{
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);
obj = lookup_object(oid->hash);
if (!obj)
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)
/* Ignore remote objects that don't exist locally */
if (!obj)
- 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",
if (!o) {
fprintf(stderr,
"Unable to parse object %s for remote ref %s\n",
warning("invalid replace ref %s", refname);
return 0;
}
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;
}
if (obj)
add_name_decoration(DECORATION_GRAFTED, "replaced", obj);
return 0;
}
- obj = parse_object(oid->hash );
+ obj = parse_object(oid);
if (!obj)
break;
if (!obj->parsed)
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;
add_name_decoration(DECORATION_REF_TAG, refname, obj);
}
return 0;
- 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)
if (!object)
return NULL;
if (object->type == OBJ_TREE)
-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 *obj;
*eaten_p = 0;
struct object *obj;
*eaten_p = 0;
- hashcpy(oid.hash, sha1);
-
obj = NULL;
if (type == OBJ_BLOB) {
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) {
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)
if (tree) {
obj = &tree->object;
if (!tree->buffer)
}
}
} else if (type == OBJ_COMMIT) {
}
}
} 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;
if (commit) {
if (parse_commit_buffer(commit, buffer, size))
return NULL;
obj = &commit->object;
}
} else if (type == OBJ_TAG) {
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 {
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;
}
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 ,
- struct object *o = parse_object(sha1 );
+ struct object *o = parse_object(oid );
- 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;
{
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;
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) ||
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) {
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 ));
- 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);
if (buffer) {
if (check_sha1_signature(repl, buffer, size, typename(type)) < 0) {
free(buffer);
- obj = parse_object_buffer(sha1 , type, size, buffer, &eaten);
+ obj = parse_object_buffer(oid , type, size, buffer, &eaten);
if (!eaten)
free(buffer);
return obj;
if (!eaten)
free(buffer);
return obj;
*
* Returns NULL if the object is missing or corrupt.
*/
*
* 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
/*
* 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.
*/
/* 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);
/** Returns the object, with potentially excess memory allocated. **/
struct object *lookup_unknown_object(const unsigned char *sha1);
struct object *object = pending_e[i].item;
if (object->type == OBJ_NONE)
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;
while (object->type == OBJ_TAG) {
struct tag *tag = (struct tag *) object;
if (!tag->tagged)
die("bad tag");
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)
}
if (object->flags & UNINTERESTING)
/* these depend on the commit */
if (!commit->object.parsed)
/* 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 */
switch (placeholder[0]) {
case 'H': /* commit hash */
- object = parse_object_or_die(oid->hash , path);
+ object = parse_object_or_die(oid, path);
add_pending_object(revs, object, "");
return 0;
add_pending_object(revs, object, "");
return 0;
switch (type) {
case OBJ_TAG:
case OBJ_COMMIT:
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);
break;
case OBJ_TREE:
obj = (struct object *)lookup_tree(oid);
void *buf = read_sha1_file(oid->hash, &type, sz);
if (buf)
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;
else
*obj = NULL;
return buf;
if (oid_array_lookup(points_at, oid) >= 0)
return oid;
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)
if (!obj)
die(_("malformed object at '%s'"), refname);
if (obj->type == OBJ_TAG)
do {
reflog = &commit_reflog->reflogs->items[commit_reflog->recno];
commit_reflog->recno--;
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];
} 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) {
}
if (!logobj || logobj->type != OBJ_COMMIT) {
struct object *o;
int fd;
struct object *o;
int fd;
- o = parse_object(oid->hash );
if (!o) {
strbuf_addf(err,
"trying to write ref '%s' with nonexistent object %s",
if (!o) {
strbuf_addf(err,
"trying to write ref '%s' with nonexistent object %s",
* Both new and old must be commit-ish and new is descendant of
* old. Otherwise we require --force.
*/
* 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;
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;
if (!o || o->type != OBJ_COMMIT)
return 0;
new = (struct commit *) o;
struct object *obj;
if (get_oid("HEAD", &oid))
return;
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");
if (!obj)
return;
add_pending_object(revs, obj, "HEAD");
- object = parse_object(oid->hash );
+ object = parse_object(oid);
if (!object) {
if (revs->ignore_missing)
return object;
if (!object) {
if (revs->ignore_missing)
return object;
add_pending_object(revs, object, tag->tag);
if (!tag->tagged)
die("bad tag");
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;
if (!object) {
if (flags & UNINTERESTING)
return NULL;
{
struct all_refs_cb *cb = cb_data;
if (!is_null_oid(oid)) {
{
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 ??? */
if (o) {
o->flags |= cb->all_flags;
/* ??? CMDLINEFLAGS ??? */
verify_non_filename(revs->prefix, arg);
}
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)
if (!a_obj || !b_obj) {
missing:
if (revs->ignore_missing)
int flag, void *cb_data)
{
FILE *fp = cb_data;
int flag, void *cb_data)
{
FILE *fp = cb_data;
- struct object *o = parse_object(oid->hash );
+ struct object *o = parse_object(oid);
return 0;
/* We need to do this the hard way... */
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;
if (obj && obj->type == OBJ_COMMIT)
return 1;
return 0;
return 0;
/* We need to do this the hard way... */
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;
if (obj && (obj->type == OBJ_TREE || obj->type == OBJ_COMMIT))
return 1;
return 0;
if (name && !namelen)
namelen = strlen(name);
while (1) {
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;
return NULL;
if (expected_type == OBJ_ANY || o->type == expected_type)
return o;
if (get_sha1_1(name, sp - name - 2, outer.hash, lookup_flags))
return -1;
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)
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;
return -1;
hashcpy(sha1, o->oid.hash);
return 0;
int flag, void *cb_data)
{
struct commit_list **list = cb_data;
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) {
if (!object)
return 0;
if (object->type == OBJ_TAG) {
int matches;
commit = pop_most_recent_commit(&list, ONELINE_SEEN);
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");
continue;
buf = get_commit_buffer(commit, NULL);
p = strstr(buf, "\n\n");
{
while (o && o->type == OBJ_TAG)
if (((struct tag *)o)->tagged)
{
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) {
else
o = NULL;
if (!o && warn) {
struct object *deref_tag_noverify(struct object *o)
{
while (o && o->type == OBJ_TAG) {
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
if (o && o->type == OBJ_TAG && ((struct tag *)o)->tagged)
o = ((struct tag *)o)->tagged;
else
struct tree *parse_tree_indirect(const struct object_id *oid)
{
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;
do {
if (!obj)
return NULL;
else
return NULL;
if (!obj->parsed)
else
return NULL;
if (!obj->parsed)
- parse_object(obj->oid.hash );
+ parse_object(&obj->oid );
if (!has_object_file(oid))
return -1;
if (!has_object_file(oid))
return -1;
- o = parse_object(oid->hash );
if (!o)
die("oops (%s)", oid_to_hex(oid));
if (o->type == OBJ_COMMIT) {
if (!o)
die("oops (%s)", oid_to_hex(oid));
if (o->type == OBJ_COMMIT) {
break;
}
if (!commit->object.parsed)
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;
if (commit->object.flags & REACHABLE)
continue;
commit->object.flags |= REACHABLE;
struct object *object;
if (get_oid_hex(arg, &oid))
die("invalid shallow line: %s", line);
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)
if (!object)
continue;
if (object->type != OBJ_COMMIT)
if (parse_feature_request(features, "include-tag"))
use_include_tag = 1;
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",
if (!o) {
packet_write_fmt(1,
"ERR upload-pack: not our ref %s",
- parse_object(obj->oid.hash );
+ parse_object(&obj->oid );
if (process_object(walker, obj))
return -1;
}
if (process_object(walker, obj))
return -1;
}