ref-filter: rename objectname
related functions and fields
In previous commits, we prepared some `objectname` related functions for more generic usage, so that these functions can be used for `tree` and `parent` atom. But the name of some functions and fields may mislead someone. For ex: function `objectname_atom_parser()` implies that it is for atom `objectname`. Let's rename all such functions and fields. Mentored-by: Christian Couder <chriscool@tuxfamily.org> Mentored-by: Heba Waly <heba.waly@gmail.com> Signed-off-by: Hariom Verma <hariom18599@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
e7601eb55b
commit
87d3beb6e0
40
ref-filter.c
40
ref-filter.c
@ -139,7 +139,7 @@ static struct used_atom {
|
|||||||
struct {
|
struct {
|
||||||
enum { O_FULL, O_LENGTH, O_SHORT } option;
|
enum { O_FULL, O_LENGTH, O_SHORT } option;
|
||||||
unsigned int length;
|
unsigned int length;
|
||||||
} objectname;
|
} oid;
|
||||||
struct email_option {
|
struct email_option {
|
||||||
enum { EO_RAW, EO_TRIM, EO_LOCALPART } option;
|
enum { EO_RAW, EO_TRIM, EO_LOCALPART } option;
|
||||||
} email_option;
|
} email_option;
|
||||||
@ -361,20 +361,20 @@ static int contents_atom_parser(const struct ref_format *format, struct used_ato
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int objectname_atom_parser(const struct ref_format *format, struct used_atom *atom,
|
static int oid_atom_parser(const struct ref_format *format, struct used_atom *atom,
|
||||||
const char *arg, struct strbuf *err)
|
const char *arg, struct strbuf *err)
|
||||||
{
|
{
|
||||||
if (!arg)
|
if (!arg)
|
||||||
atom->u.objectname.option = O_FULL;
|
atom->u.oid.option = O_FULL;
|
||||||
else if (!strcmp(arg, "short"))
|
else if (!strcmp(arg, "short"))
|
||||||
atom->u.objectname.option = O_SHORT;
|
atom->u.oid.option = O_SHORT;
|
||||||
else if (skip_prefix(arg, "short=", &arg)) {
|
else if (skip_prefix(arg, "short=", &arg)) {
|
||||||
atom->u.objectname.option = O_LENGTH;
|
atom->u.oid.option = O_LENGTH;
|
||||||
if (strtoul_ui(arg, 10, &atom->u.objectname.length) ||
|
if (strtoul_ui(arg, 10, &atom->u.oid.length) ||
|
||||||
atom->u.objectname.length == 0)
|
atom->u.oid.length == 0)
|
||||||
return strbuf_addf_ret(err, -1, _("positive value expected '%s' in %%(%s)"), arg, atom->name);
|
return strbuf_addf_ret(err, -1, _("positive value expected '%s' in %%(%s)"), arg, atom->name);
|
||||||
if (atom->u.objectname.length < MINIMUM_ABBREV)
|
if (atom->u.oid.length < MINIMUM_ABBREV)
|
||||||
atom->u.objectname.length = MINIMUM_ABBREV;
|
atom->u.oid.length = MINIMUM_ABBREV;
|
||||||
} else
|
} else
|
||||||
return strbuf_addf_ret(err, -1, _("unrecognized argument '%s' in %%(%s)"), arg, atom->name);
|
return strbuf_addf_ret(err, -1, _("unrecognized argument '%s' in %%(%s)"), arg, atom->name);
|
||||||
return 0;
|
return 0;
|
||||||
@ -495,7 +495,7 @@ static struct {
|
|||||||
{ "refname", SOURCE_NONE, FIELD_STR, refname_atom_parser },
|
{ "refname", SOURCE_NONE, FIELD_STR, refname_atom_parser },
|
||||||
{ "objecttype", SOURCE_OTHER, FIELD_STR, objecttype_atom_parser },
|
{ "objecttype", SOURCE_OTHER, FIELD_STR, objecttype_atom_parser },
|
||||||
{ "objectsize", SOURCE_OTHER, FIELD_ULONG, objectsize_atom_parser },
|
{ "objectsize", SOURCE_OTHER, FIELD_ULONG, objectsize_atom_parser },
|
||||||
{ "objectname", SOURCE_OTHER, FIELD_STR, objectname_atom_parser },
|
{ "objectname", SOURCE_OTHER, FIELD_STR, oid_atom_parser },
|
||||||
{ "deltabase", SOURCE_OTHER, FIELD_STR, deltabase_atom_parser },
|
{ "deltabase", SOURCE_OTHER, FIELD_STR, deltabase_atom_parser },
|
||||||
{ "tree", SOURCE_OBJ },
|
{ "tree", SOURCE_OBJ },
|
||||||
{ "parent", SOURCE_OBJ },
|
{ "parent", SOURCE_OBJ },
|
||||||
@ -918,14 +918,14 @@ int verify_ref_format(struct ref_format *format)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *do_grab_objectname(const char *field, const struct object_id *oid,
|
static const char *do_grab_oid(const char *field, const struct object_id *oid,
|
||||||
struct used_atom *atom)
|
struct used_atom *atom)
|
||||||
{
|
{
|
||||||
switch (atom->u.objectname.option) {
|
switch (atom->u.oid.option) {
|
||||||
case O_FULL:
|
case O_FULL:
|
||||||
return oid_to_hex(oid);
|
return oid_to_hex(oid);
|
||||||
case O_LENGTH:
|
case O_LENGTH:
|
||||||
return find_unique_abbrev(oid, atom->u.objectname.length);
|
return find_unique_abbrev(oid, atom->u.oid.length);
|
||||||
case O_SHORT:
|
case O_SHORT:
|
||||||
return find_unique_abbrev(oid, DEFAULT_ABBREV);
|
return find_unique_abbrev(oid, DEFAULT_ABBREV);
|
||||||
default:
|
default:
|
||||||
@ -933,11 +933,11 @@ static const char *do_grab_objectname(const char *field, const struct object_id
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int grab_objectname(const char *name, const char *field, const struct object_id *oid,
|
static int grab_oid(const char *name, const char *field, const struct object_id *oid,
|
||||||
struct atom_value *v, struct used_atom *atom)
|
struct atom_value *v, struct used_atom *atom)
|
||||||
{
|
{
|
||||||
if (starts_with(name, field)) {
|
if (starts_with(name, field)) {
|
||||||
v->s = xstrdup(do_grab_objectname(field, oid, atom));
|
v->s = xstrdup(do_grab_oid(field, oid, atom));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -966,7 +966,7 @@ static void grab_common_values(struct atom_value *val, int deref, struct expand_
|
|||||||
} else if (!strcmp(name, "deltabase"))
|
} else if (!strcmp(name, "deltabase"))
|
||||||
v->s = xstrdup(oid_to_hex(&oi->delta_base_oid));
|
v->s = xstrdup(oid_to_hex(&oi->delta_base_oid));
|
||||||
else if (deref)
|
else if (deref)
|
||||||
grab_objectname(name, "objectname", &oi->oid, v, &used_atom[i]);
|
grab_oid(name, "objectname", &oi->oid, v, &used_atom[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1746,7 +1746,7 @@ static int populate_value(struct ref_array_item *ref, struct strbuf *err)
|
|||||||
v->s = xstrdup(buf + 1);
|
v->s = xstrdup(buf + 1);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
} else if (!deref && grab_objectname(name, "objectname", &ref->objectname, v, atom)) {
|
} else if (!deref && grab_oid(name, "objectname", &ref->objectname, v, atom)) {
|
||||||
continue;
|
continue;
|
||||||
} else if (!strcmp(name, "HEAD")) {
|
} else if (!strcmp(name, "HEAD")) {
|
||||||
if (atom->u.head && !strcmp(ref->refname, atom->u.head))
|
if (atom->u.head && !strcmp(ref->refname, atom->u.head))
|
||||||
|
Loading…
Reference in New Issue
Block a user