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 <christian.couder@gmail.com> Mentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr> Signed-off-by: Karthik Nayak <karthik.188@gmail.com> Reviewed-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Karthik Nayak committed
Jun 14, 2015 at 01:07 UTC
58792320903eb58ac88cb97c280a759f89c3b8fa
1 file changed
+20
-20
builtin/for-each-ref.c
+20
-20
@@ -31,12 +31,12 @@ struct ref_sort {
31
unsigned reverse : 1;
32
};
33
34
-struct refinfo {
35
- char *refname;
34
+struct ref_array_item {
35
unsigned char objectname[20];
36
int flag;
37
const char *symref;
38
struct atom_value *value;
39
+ char *refname;
40
};
41
42
static struct {
@@ -86,7 +86,7 @@ static struct {
86
* a "*" to denote deref_tag().
87
*
88
* 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
90
* structure will hold an array of values extracted that can be
91
* indexed with the "atom number", which is an index into this
92
* array.
@@ -623,7 +623,7 @@ static inline char *copy_advance(char *dst, const char *src)
623
/*
624
* Parse the object referred by ref, and grab needed value.
625
*/
626
-static void populate_value(struct refinfo *ref)
626
+static void populate_value(struct ref_array_item *ref)
627
{
628
void *buf;
629
struct object *obj;
@@ -835,7 +835,7 @@ static void populate_value(struct refinfo *ref)
835
* Given a ref, return the value for the atom. This lazily gets value
836
* out of the object by calling populate value.
837
*/
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)
839
{
840
if (!ref->value) {
841
populate_value(ref);
@@ -845,7 +845,7 @@ static void get_value(struct refinfo *ref, int atom, struct atom_value **v)
845
}
846
847
struct grab_ref_cbdata {
848
- struct refinfo **grab_array;
848
+ struct ref_array_item **grab_array;
849
const char **grab_pattern;
850
int grab_cnt;
851
};
@@ -875,12 +875,12 @@ static int match_name_as_path(const char **pattern, const char *refname)
875
return 0;
876
}
877
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)
882
{
883
- struct refinfo *ref = xcalloc(1, sizeof(struct refinfo));
883
+ struct ref_array_item *ref = xcalloc(1, sizeof(struct ref_array_item));
884
ref->refname = xstrdup(refname);
885
hashcpy(ref->objectname, objectname);
886
ref->flag = flag;
@@ -896,7 +896,7 @@ static int grab_single_ref(const char *refname, const struct object_id *oid,
896
int flag, void *cb_data)
897
{
898
struct grab_ref_cbdata *cb = cb_data;
899
- struct refinfo *ref;
899
+ struct ref_array_item *ref;
900
901
if (flag & REF_BAD_NAME) {
902
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,
911
* to do its job and the resulting list may yet to be pruned
912
* by maxcount logic.
913
*/
914
- ref = new_refinfo(refname, oid->hash, flag);
914
+ ref = new_ref_array_item(refname, oid->hash, flag);
915
916
REALLOC_ARRAY(cb->grab_array, cb->grab_cnt + 1);
917
cb->grab_array[cb->grab_cnt++] = ref;
918
return 0;
919
}
920
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)
922
{
923
struct atom_value *va, *vb;
924
int cmp;
@@ -945,8 +945,8 @@ static int cmp_ref_sort(struct ref_sort *s, struct refinfo *a, struct refinfo *b
945
static struct ref_sort *ref_sort;
946
static int compare_refs(const void *a_, const void *b_)
947
{
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_);
950
struct ref_sort *s;
951
952
for (s = ref_sort; s; s = s->next) {
@@ -957,10 +957,10 @@ static int compare_refs(const void *a_, const void *b_)
957
return 0;
958
}
959
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)
961
{
962
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);
964
}
965
966
static void print_value(struct atom_value *v, int quote_style)
@@ -1027,7 +1027,7 @@ static void emit(const char *cp, const char *ep)
1027
}
1028
}
1029
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)
1031
{
1032
const char *cp, *sp, *ep;
1033
@@ -1100,7 +1100,7 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)
1100
const char *format = "%(objectname) %(objecttype)\t%(refname)";
1101
struct ref_sort *sort = NULL, **sort_tail = &sort;
1102
int maxcount = 0, quote_style = 0;
1103
- struct refinfo **refs;
1103
+ struct ref_array_item **refs;
1104
struct grab_ref_cbdata cbdata;
1105
1106
struct option opts[] = {