Skip to content

Commit 87d3beb

Browse files
harry-hovgitster
authored andcommitted
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 <[email protected]> Mentored-by: Heba Waly <[email protected]> Signed-off-by: Hariom Verma <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e7601eb commit 87d3beb

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

ref-filter.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ static struct used_atom {
139139
struct {
140140
enum { O_FULL, O_LENGTH, O_SHORT } option;
141141
unsigned int length;
142-
} objectname;
142+
} oid;
143143
struct email_option {
144144
enum { EO_RAW, EO_TRIM, EO_LOCALPART } option;
145145
} email_option;
@@ -361,20 +361,20 @@ static int contents_atom_parser(const struct ref_format *format, struct used_ato
361361
return 0;
362362
}
363363

364-
static int objectname_atom_parser(const struct ref_format *format, struct used_atom *atom,
365-
const char *arg, struct strbuf *err)
364+
static int oid_atom_parser(const struct ref_format *format, struct used_atom *atom,
365+
const char *arg, struct strbuf *err)
366366
{
367367
if (!arg)
368-
atom->u.objectname.option = O_FULL;
368+
atom->u.oid.option = O_FULL;
369369
else if (!strcmp(arg, "short"))
370-
atom->u.objectname.option = O_SHORT;
370+
atom->u.oid.option = O_SHORT;
371371
else if (skip_prefix(arg, "short=", &arg)) {
372-
atom->u.objectname.option = O_LENGTH;
373-
if (strtoul_ui(arg, 10, &atom->u.objectname.length) ||
374-
atom->u.objectname.length == 0)
372+
atom->u.oid.option = O_LENGTH;
373+
if (strtoul_ui(arg, 10, &atom->u.oid.length) ||
374+
atom->u.oid.length == 0)
375375
return strbuf_addf_ret(err, -1, _("positive value expected '%s' in %%(%s)"), arg, atom->name);
376-
if (atom->u.objectname.length < MINIMUM_ABBREV)
377-
atom->u.objectname.length = MINIMUM_ABBREV;
376+
if (atom->u.oid.length < MINIMUM_ABBREV)
377+
atom->u.oid.length = MINIMUM_ABBREV;
378378
} else
379379
return strbuf_addf_ret(err, -1, _("unrecognized argument '%s' in %%(%s)"), arg, atom->name);
380380
return 0;
@@ -495,7 +495,7 @@ static struct {
495495
{ "refname", SOURCE_NONE, FIELD_STR, refname_atom_parser },
496496
{ "objecttype", SOURCE_OTHER, FIELD_STR, objecttype_atom_parser },
497497
{ "objectsize", SOURCE_OTHER, FIELD_ULONG, objectsize_atom_parser },
498-
{ "objectname", SOURCE_OTHER, FIELD_STR, objectname_atom_parser },
498+
{ "objectname", SOURCE_OTHER, FIELD_STR, oid_atom_parser },
499499
{ "deltabase", SOURCE_OTHER, FIELD_STR, deltabase_atom_parser },
500500
{ "tree", SOURCE_OBJ },
501501
{ "parent", SOURCE_OBJ },
@@ -918,26 +918,26 @@ int verify_ref_format(struct ref_format *format)
918918
return 0;
919919
}
920920

921-
static const char *do_grab_objectname(const char *field, const struct object_id *oid,
922-
struct used_atom *atom)
921+
static const char *do_grab_oid(const char *field, const struct object_id *oid,
922+
struct used_atom *atom)
923923
{
924-
switch (atom->u.objectname.option) {
924+
switch (atom->u.oid.option) {
925925
case O_FULL:
926926
return oid_to_hex(oid);
927927
case O_LENGTH:
928-
return find_unique_abbrev(oid, atom->u.objectname.length);
928+
return find_unique_abbrev(oid, atom->u.oid.length);
929929
case O_SHORT:
930930
return find_unique_abbrev(oid, DEFAULT_ABBREV);
931931
default:
932932
BUG("unknown %%(%s) option", field);
933933
}
934934
}
935935

936-
static int grab_objectname(const char *name, const char *field, const struct object_id *oid,
937-
struct atom_value *v, struct used_atom *atom)
936+
static int grab_oid(const char *name, const char *field, const struct object_id *oid,
937+
struct atom_value *v, struct used_atom *atom)
938938
{
939939
if (starts_with(name, field)) {
940-
v->s = xstrdup(do_grab_objectname(field, oid, atom));
940+
v->s = xstrdup(do_grab_oid(field, oid, atom));
941941
return 1;
942942
}
943943
return 0;
@@ -966,7 +966,7 @@ static void grab_common_values(struct atom_value *val, int deref, struct expand_
966966
} else if (!strcmp(name, "deltabase"))
967967
v->s = xstrdup(oid_to_hex(&oi->delta_base_oid));
968968
else if (deref)
969-
grab_objectname(name, "objectname", &oi->oid, v, &used_atom[i]);
969+
grab_oid(name, "objectname", &oi->oid, v, &used_atom[i]);
970970
}
971971
}
972972

@@ -1746,7 +1746,7 @@ static int populate_value(struct ref_array_item *ref, struct strbuf *err)
17461746
v->s = xstrdup(buf + 1);
17471747
}
17481748
continue;
1749-
} else if (!deref && grab_objectname(name, "objectname", &ref->objectname, v, atom)) {
1749+
} else if (!deref && grab_oid(name, "objectname", &ref->objectname, v, atom)) {
17501750
continue;
17511751
} else if (!strcmp(name, "HEAD")) {
17521752
if (atom->u.head && !strcmp(ref->refname, atom->u.head))

0 commit comments

Comments
 (0)