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>
Hariom Verma committed
Aug 21, 2020 at 21:41 UTC
87d3beb6e0eedfb83a8dd425e3c612d977b6ac8d
1 file changed
+20
-20
ref-filter.c
+20
-20
@@ -139,7 +139,7 @@ static struct used_atom {
139
struct {
140
enum { O_FULL, O_LENGTH, O_SHORT } option;
141
unsigned int length;
142
- } objectname;
142
+ } oid;
143
struct email_option {
144
enum { EO_RAW, EO_TRIM, EO_LOCALPART } option;
145
} email_option;
@@ -361,20 +361,20 @@ static int contents_atom_parser(const struct ref_format *format, struct used_ato
361
return 0;
362
}
363
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)
366
{
367
if (!arg)
368
- atom->u.objectname.option = O_FULL;
368
+ atom->u.oid.option = O_FULL;
369
else if (!strcmp(arg, "short"))
370
- atom->u.objectname.option = O_SHORT;
370
+ atom->u.oid.option = O_SHORT;
371
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)
375
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;
378
} else
379
return strbuf_addf_ret(err, -1, _("unrecognized argument '%s' in %%(%s)"), arg, atom->name);
380
return 0;
@@ -495,7 +495,7 @@ static struct {
495
{ "refname", SOURCE_NONE, FIELD_STR, refname_atom_parser },
496
{ "objecttype", SOURCE_OTHER, FIELD_STR, objecttype_atom_parser },
497
{ "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 },
499
{ "deltabase", SOURCE_OTHER, FIELD_STR, deltabase_atom_parser },
500
{ "tree", SOURCE_OBJ },
501
{ "parent", SOURCE_OBJ },
@@ -918,14 +918,14 @@ int verify_ref_format(struct ref_format *format)
918
return 0;
919
}
920
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)
923
{
924
- switch (atom->u.objectname.option) {
924
+ switch (atom->u.oid.option) {
925
case O_FULL:
926
return oid_to_hex(oid);
927
case O_LENGTH:
928
- return find_unique_abbrev(oid, atom->u.objectname.length);
928
+ return find_unique_abbrev(oid, atom->u.oid.length);
929
case O_SHORT:
930
return find_unique_abbrev(oid, DEFAULT_ABBREV);
931
default:
@@ -933,11 +933,11 @@ static const char *do_grab_objectname(const char *field, const struct object_id
933
}
934
}
935
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)
938
{
939
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));
941
return 1;
942
}
943
return 0;
@@ -966,7 +966,7 @@ static void grab_common_values(struct atom_value *val, int deref, struct expand_
966
} else if (!strcmp(name, "deltabase"))
967
v->s = xstrdup(oid_to_hex(&oi->delta_base_oid));
968
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]);
970
}
971
}
972
@@ -1746,7 +1746,7 @@ static int populate_value(struct ref_array_item *ref, struct strbuf *err)
1746
v->s = xstrdup(buf + 1);
1747
}
1748
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)) {
1750
continue;
1751
} else if (!strcmp(name, "HEAD")) {
1752
if (atom->u.head && !strcmp(ref->refname, atom->u.head))