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
committed by Junio C Hamano
parent a9dbc17910
commit c251c83df2
38 changed files with 107 additions and 108 deletions

View File

@ -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",