Skip to content

Commit 5879232

Browse files
KarthikNayakgitster
authored andcommitted
for-each-ref: rename 'refinfo' to 'ref_array_item'
Rename 'refinfo' to 'ref_array_item' as a preparatory step for introduction of new structures in the forthcoming patch. Re-order the fields in 'ref_array_item' so that refname can be eventually converted to a FLEX_ARRAY. Mentored-by: Christian Couder <[email protected]> Mentored-by: Matthieu Moy <[email protected]> Signed-off-by: Karthik Nayak <[email protected]> Reviewed-by: Matthieu Moy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fc80edc commit 5879232

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

builtin/for-each-ref.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ struct ref_sort {
3131
unsigned reverse : 1;
3232
};
3333

34-
struct refinfo {
35-
char *refname;
34+
struct ref_array_item {
3635
unsigned char objectname[20];
3736
int flag;
3837
const char *symref;
3938
struct atom_value *value;
39+
char *refname;
4040
};
4141

4242
static struct {
@@ -86,7 +86,7 @@ static struct {
8686
* a "*" to denote deref_tag().
8787
*
8888
* We parse given format string and sort specifiers, and make a list
89-
* of properties that we need to extract out of objects. refinfo
89+
* of properties that we need to extract out of objects. ref_array_item
9090
* structure will hold an array of values extracted that can be
9191
* indexed with the "atom number", which is an index into this
9292
* array.
@@ -623,7 +623,7 @@ static inline char *copy_advance(char *dst, const char *src)
623623
/*
624624
* Parse the object referred by ref, and grab needed value.
625625
*/
626-
static void populate_value(struct refinfo *ref)
626+
static void populate_value(struct ref_array_item *ref)
627627
{
628628
void *buf;
629629
struct object *obj;
@@ -835,7 +835,7 @@ static void populate_value(struct refinfo *ref)
835835
* Given a ref, return the value for the atom. This lazily gets value
836836
* out of the object by calling populate value.
837837
*/
838-
static void get_value(struct refinfo *ref, int atom, struct atom_value **v)
838+
static void get_value(struct ref_array_item *ref, int atom, struct atom_value **v)
839839
{
840840
if (!ref->value) {
841841
populate_value(ref);
@@ -845,7 +845,7 @@ static void get_value(struct refinfo *ref, int atom, struct atom_value **v)
845845
}
846846

847847
struct grab_ref_cbdata {
848-
struct refinfo **grab_array;
848+
struct ref_array_item **grab_array;
849849
const char **grab_pattern;
850850
int grab_cnt;
851851
};
@@ -875,12 +875,12 @@ static int match_name_as_path(const char **pattern, const char *refname)
875875
return 0;
876876
}
877877

878-
/* Allocate space for a new refinfo and copy the objectname and flag to it */
879-
static struct refinfo *new_refinfo(const char *refname,
880-
const unsigned char *objectname,
881-
int flag)
878+
/* Allocate space for a new ref_array_item and copy the objectname and flag to it */
879+
static struct ref_array_item *new_ref_array_item(const char *refname,
880+
const unsigned char *objectname,
881+
int flag)
882882
{
883-
struct refinfo *ref = xcalloc(1, sizeof(struct refinfo));
883+
struct ref_array_item *ref = xcalloc(1, sizeof(struct ref_array_item));
884884
ref->refname = xstrdup(refname);
885885
hashcpy(ref->objectname, objectname);
886886
ref->flag = flag;
@@ -896,7 +896,7 @@ static int grab_single_ref(const char *refname, const struct object_id *oid,
896896
int flag, void *cb_data)
897897
{
898898
struct grab_ref_cbdata *cb = cb_data;
899-
struct refinfo *ref;
899+
struct ref_array_item *ref;
900900

901901
if (flag & REF_BAD_NAME) {
902902
warning("ignoring ref with broken name %s", refname);
@@ -911,14 +911,14 @@ static int grab_single_ref(const char *refname, const struct object_id *oid,
911911
* to do its job and the resulting list may yet to be pruned
912912
* by maxcount logic.
913913
*/
914-
ref = new_refinfo(refname, oid->hash, flag);
914+
ref = new_ref_array_item(refname, oid->hash, flag);
915915

916916
REALLOC_ARRAY(cb->grab_array, cb->grab_cnt + 1);
917917
cb->grab_array[cb->grab_cnt++] = ref;
918918
return 0;
919919
}
920920

921-
static int cmp_ref_sort(struct ref_sort *s, struct refinfo *a, struct refinfo *b)
921+
static int cmp_ref_sort(struct ref_sort *s, struct ref_array_item *a, struct ref_array_item *b)
922922
{
923923
struct atom_value *va, *vb;
924924
int cmp;
@@ -945,8 +945,8 @@ static int cmp_ref_sort(struct ref_sort *s, struct refinfo *a, struct refinfo *b
945945
static struct ref_sort *ref_sort;
946946
static int compare_refs(const void *a_, const void *b_)
947947
{
948-
struct refinfo *a = *((struct refinfo **)a_);
949-
struct refinfo *b = *((struct refinfo **)b_);
948+
struct ref_array_item *a = *((struct ref_array_item **)a_);
949+
struct ref_array_item *b = *((struct ref_array_item **)b_);
950950
struct ref_sort *s;
951951

952952
for (s = ref_sort; s; s = s->next) {
@@ -957,10 +957,10 @@ static int compare_refs(const void *a_, const void *b_)
957957
return 0;
958958
}
959959

960-
static void sort_refs(struct ref_sort *sort, struct refinfo **refs, int num_refs)
960+
static void sort_refs(struct ref_sort *sort, struct ref_array_item **refs, int num_refs)
961961
{
962962
ref_sort = sort;
963-
qsort(refs, num_refs, sizeof(struct refinfo *), compare_refs);
963+
qsort(refs, num_refs, sizeof(struct ref_array_item *), compare_refs);
964964
}
965965

966966
static void print_value(struct atom_value *v, int quote_style)
@@ -1027,7 +1027,7 @@ static void emit(const char *cp, const char *ep)
10271027
}
10281028
}
10291029

1030-
static void show_ref(struct refinfo *info, const char *format, int quote_style)
1030+
static void show_ref(struct ref_array_item *info, const char *format, int quote_style)
10311031
{
10321032
const char *cp, *sp, *ep;
10331033

@@ -1100,7 +1100,7 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)
11001100
const char *format = "%(objectname) %(objecttype)\t%(refname)";
11011101
struct ref_sort *sort = NULL, **sort_tail = &sort;
11021102
int maxcount = 0, quote_style = 0;
1103-
struct refinfo **refs;
1103+
struct ref_array_item **refs;
11041104
struct grab_ref_cbdata cbdata;
11051105

11061106
struct option opts[] = {

0 commit comments

Comments
 (0)