ref-filter: convert some static functions to struct object_id
Among the converted functions is a caller of parse_object_buffer, which we will convert later. 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
9850fe5d95ac14585998e6ebeaf158c976954b1b
1 file changed
+10
-10
ref-filter.c
+10
-10
@@ -677,13 +677,13 @@ int verify_ref_format(const char *format)
677
* by the "struct object" representation, set *eaten as well---it is a
678
* signal from parse_object_buffer to us not to free the buffer.
679
*/
680
-static void *get_obj(const unsigned char *sha1, struct object **obj, unsigned long *sz, int *eaten)
680
+static void *get_obj(const struct object_id *oid, struct object **obj, unsigned long *sz, int *eaten)
681
{
682
enum object_type type;
683
- void *buf = read_sha1_file(sha1, &type, sz);
683
+ void *buf = read_sha1_file(oid->hash, &type, sz);
684
685
if (buf)
686
- *obj = parse_object_buffer(sha1, type, *sz, buf, eaten);
686
+ *obj = parse_object_buffer(oid->hash, type, *sz, buf, eaten);
687
else
688
*obj = NULL;
689
return buf;
@@ -1293,7 +1293,7 @@ static void populate_value(struct ref_array_item *ref)
1293
struct object *obj;
1294
int eaten, i;
1295
unsigned long size;
1296
- const unsigned char *tagged;
1296
+ const struct object_id *tagged;
1297
1298
ref->value = xcalloc(used_atom_cnt, sizeof(struct atom_value));
1299
@@ -1370,10 +1370,10 @@ static void populate_value(struct ref_array_item *ref)
1370
continue;
1371
} else if (!strcmp(name, "HEAD")) {
1372
const char *head;
1373
- unsigned char sha1[20];
1373
+ struct object_id oid;
1374
1375
head = resolve_ref_unsafe("HEAD", RESOLVE_REF_READING,
1376
- sha1, NULL);
1376
+ oid.hash, NULL);
1377
if (head && !strcmp(ref->refname, head))
1378
v->s = "*";
1379
else
@@ -1415,7 +1415,7 @@ static void populate_value(struct ref_array_item *ref)
1415
return;
1416
1417
need_obj:
1418
- buf = get_obj(ref->objectname.hash, &obj, &size, &eaten);
1418
+ buf = get_obj(&ref->objectname, &obj, &size, &eaten);
1419
if (!buf)
1420
die(_("missing object %s for %s"),
1421
oid_to_hex(&ref->objectname), ref->refname);
@@ -1438,7 +1438,7 @@ static void populate_value(struct ref_array_item *ref)
1438
* If it is a tag object, see if we use a value that derefs
1439
* the object, and if we do grab the object it refers to.
1440
*/
1441
- tagged = ((struct tag *)obj)->tagged->oid.hash;
1441
+ tagged = &((struct tag *)obj)->tagged->oid;
1442
1443
/*
1444
* NEEDSWORK: This derefs tag only once, which
@@ -1449,10 +1449,10 @@ static void populate_value(struct ref_array_item *ref)
1449
buf = get_obj(tagged, &obj, &size, &eaten);
1450
if (!buf)
1451
die(_("missing object %s for %s"),
1452
- sha1_to_hex(tagged), ref->refname);
1452
+ oid_to_hex(tagged), ref->refname);
1453
if (!obj)
1454
die(_("parse_object_buffer failed on %s for %s"),
1455
- sha1_to_hex(tagged), ref->refname);
1455
+ oid_to_hex(tagged), ref->refname);
1456
grab_values(ref->value, 1, obj, buf, size);
1457
if (!eaten)
1458
free(buf);