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>
This commit is contained in:
parent
cedfc41ac6
commit
9850fe5d95
20
ref-filter.c
20
ref-filter.c
@ -677,13 +677,13 @@ int verify_ref_format(const char *format)
|
|||||||
* by the "struct object" representation, set *eaten as well---it is a
|
* by the "struct object" representation, set *eaten as well---it is a
|
||||||
* signal from parse_object_buffer to us not to free the buffer.
|
* signal from parse_object_buffer to us not to free the buffer.
|
||||||
*/
|
*/
|
||||||
static void *get_obj(const unsigned char *sha1, struct object **obj, unsigned long *sz, int *eaten)
|
static void *get_obj(const struct object_id *oid, struct object **obj, unsigned long *sz, int *eaten)
|
||||||
{
|
{
|
||||||
enum object_type type;
|
enum object_type type;
|
||||||
void *buf = read_sha1_file(sha1, &type, sz);
|
void *buf = read_sha1_file(oid->hash, &type, sz);
|
||||||
|
|
||||||
if (buf)
|
if (buf)
|
||||||
*obj = parse_object_buffer(sha1, type, *sz, buf, eaten);
|
*obj = parse_object_buffer(oid->hash, type, *sz, buf, eaten);
|
||||||
else
|
else
|
||||||
*obj = NULL;
|
*obj = NULL;
|
||||||
return buf;
|
return buf;
|
||||||
@ -1293,7 +1293,7 @@ static void populate_value(struct ref_array_item *ref)
|
|||||||
struct object *obj;
|
struct object *obj;
|
||||||
int eaten, i;
|
int eaten, i;
|
||||||
unsigned long size;
|
unsigned long size;
|
||||||
const unsigned char *tagged;
|
const struct object_id *tagged;
|
||||||
|
|
||||||
ref->value = xcalloc(used_atom_cnt, sizeof(struct atom_value));
|
ref->value = xcalloc(used_atom_cnt, sizeof(struct atom_value));
|
||||||
|
|
||||||
@ -1370,10 +1370,10 @@ static void populate_value(struct ref_array_item *ref)
|
|||||||
continue;
|
continue;
|
||||||
} else if (!strcmp(name, "HEAD")) {
|
} else if (!strcmp(name, "HEAD")) {
|
||||||
const char *head;
|
const char *head;
|
||||||
unsigned char sha1[20];
|
struct object_id oid;
|
||||||
|
|
||||||
head = resolve_ref_unsafe("HEAD", RESOLVE_REF_READING,
|
head = resolve_ref_unsafe("HEAD", RESOLVE_REF_READING,
|
||||||
sha1, NULL);
|
oid.hash, NULL);
|
||||||
if (head && !strcmp(ref->refname, head))
|
if (head && !strcmp(ref->refname, head))
|
||||||
v->s = "*";
|
v->s = "*";
|
||||||
else
|
else
|
||||||
@ -1415,7 +1415,7 @@ static void populate_value(struct ref_array_item *ref)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
need_obj:
|
need_obj:
|
||||||
buf = get_obj(ref->objectname.hash, &obj, &size, &eaten);
|
buf = get_obj(&ref->objectname, &obj, &size, &eaten);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
die(_("missing object %s for %s"),
|
die(_("missing object %s for %s"),
|
||||||
oid_to_hex(&ref->objectname), ref->refname);
|
oid_to_hex(&ref->objectname), ref->refname);
|
||||||
@ -1438,7 +1438,7 @@ static void populate_value(struct ref_array_item *ref)
|
|||||||
* If it is a tag object, see if we use a value that derefs
|
* If it is a tag object, see if we use a value that derefs
|
||||||
* the object, and if we do grab the object it refers to.
|
* the object, and if we do grab the object it refers to.
|
||||||
*/
|
*/
|
||||||
tagged = ((struct tag *)obj)->tagged->oid.hash;
|
tagged = &((struct tag *)obj)->tagged->oid;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NEEDSWORK: This derefs tag only once, which
|
* NEEDSWORK: This derefs tag only once, which
|
||||||
@ -1449,10 +1449,10 @@ static void populate_value(struct ref_array_item *ref)
|
|||||||
buf = get_obj(tagged, &obj, &size, &eaten);
|
buf = get_obj(tagged, &obj, &size, &eaten);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
die(_("missing object %s for %s"),
|
die(_("missing object %s for %s"),
|
||||||
sha1_to_hex(tagged), ref->refname);
|
oid_to_hex(tagged), ref->refname);
|
||||||
if (!obj)
|
if (!obj)
|
||||||
die(_("parse_object_buffer failed on %s for %s"),
|
die(_("parse_object_buffer failed on %s for %s"),
|
||||||
sha1_to_hex(tagged), ref->refname);
|
oid_to_hex(tagged), ref->refname);
|
||||||
grab_values(ref->value, 1, obj, buf, size);
|
grab_values(ref->value, 1, obj, buf, size);
|
||||||
if (!eaten)
|
if (!eaten)
|
||||||
free(buf);
|
free(buf);
|
||||||
|
Loading…
Reference in New Issue
Block a user