Convert struct ref_array_item to struct object_id
Convert struct ref_array_item to use struct object_id by changing the definition and applying the following semantic patch, plus the standard object_id transforms: @@ struct ref_array_item E1; @@ - E1.objectname + E1.objectname.hash @@ struct ref_array_item *E1; @@ - E1->objectname + E1->objectname.hash This transformation allows us to convert get_obj, which is needed to convert parse_object_buffer. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
brian m. carlson committed
May 6, 2017 at 22:10 UTC
cedfc41ac62c691557263a8db41f7f693914d68d
2 files changed
+6
-6
ref-filter.c
+5
-5
@@ -1366,7 +1366,7 @@ static void populate_value(struct ref_array_item *ref)
1366
v->s = xstrdup(buf + 1);
1367
}
1368
continue;
1369
- } else if (!deref && grab_objectname(name, ref->objectname, v, atom)) {
1369
+ } else if (!deref && grab_objectname(name, ref->objectname.hash, v, atom)) {
1370
continue;
1371
} else if (!strcmp(name, "HEAD")) {
1372
const char *head;
@@ -1415,13 +1415,13 @@ static void populate_value(struct ref_array_item *ref)
1415
return;
1416
1417
need_obj:
1418
- buf = get_obj(ref->objectname, &obj, &size, &eaten);
1418
+ buf = get_obj(ref->objectname.hash, &obj, &size, &eaten);
1419
if (!buf)
1420
die(_("missing object %s for %s"),
1421
- sha1_to_hex(ref->objectname), ref->refname);
1421
+ oid_to_hex(&ref->objectname), ref->refname);
1422
if (!obj)
1423
die(_("parse_object_buffer failed on %s for %s"),
1424
- sha1_to_hex(ref->objectname), ref->refname);
1424
+ oid_to_hex(&ref->objectname), ref->refname);
1425
1426
grab_values(ref->value, 0, obj, buf, size);
1427
if (!eaten)
@@ -1704,7 +1704,7 @@ static struct ref_array_item *new_ref_array_item(const char *refname,
1704
{
1705
struct ref_array_item *ref;
1706
FLEX_ALLOC_STR(ref, refname, refname);
1707
- hashcpy(ref->objectname, objectname);
1707
+ hashcpy(ref->objectname.hash, objectname);
1708
ref->flag = flag;
1709
1710
return ref;
ref-filter.h
+1
-1
@@ -34,7 +34,7 @@ struct ref_sorting {
34
};
35
36
struct ref_array_item {
37
- unsigned char objectname[20];
37
+ struct object_id objectname;
38
int flag;
39
unsigned int kind;
40
const char *symref;