@@ -113,7 +113,7 @@ static int need_color_reset_at_eol;
113
113
/*
114
114
* Used to parse format string and sort specifiers
115
115
*/
116
- static int parse_atom (const char * atom , const char * ep )
116
+ int parse_ref_filter_atom (const char * atom , const char * ep )
117
117
{
118
118
const char * sp ;
119
119
int i , at ;
@@ -190,7 +190,7 @@ static const char *find_next(const char *cp)
190
190
* Make sure the format string is well formed, and parse out
191
191
* the used atoms.
192
192
*/
193
- static int verify_format (const char * format )
193
+ int verify_ref_format (const char * format )
194
194
{
195
195
const char * cp , * sp ;
196
196
@@ -202,7 +202,7 @@ static int verify_format(const char *format)
202
202
if (!ep )
203
203
return error ("malformed format string %s" , sp );
204
204
/* sp points at "%(" and ep points at the closing ")" */
205
- at = parse_atom (sp + 2 , ep );
205
+ at = parse_ref_filter_atom (sp + 2 , ep );
206
206
cp = ep + 1 ;
207
207
208
208
if (skip_prefix (used_atom [at ], "color:" , & color ))
@@ -409,7 +409,7 @@ static void grab_date(const char *buf, struct atom_value *v, const char *atomnam
409
409
/*
410
410
* We got here because atomname ends in "date" or "date<something>";
411
411
* it's not possible that <something> is not ":<format>" because
412
- * parse_atom () wouldn't have allowed it, so we can assume that no
412
+ * parse_ref_filter_atom () wouldn't have allowed it, so we can assume that no
413
413
* ":" means no format is specified, and use the default.
414
414
*/
415
415
formatp = strchr (atomname , ':' );
@@ -849,7 +849,7 @@ static void populate_value(struct ref_array_item *ref)
849
849
* Given a ref, return the value for the atom. This lazily gets value
850
850
* out of the object by calling populate value.
851
851
*/
852
- static void get_value (struct ref_array_item * ref , int atom , struct atom_value * * v )
852
+ static void get_ref_atom_value (struct ref_array_item * ref , int atom , struct atom_value * * v )
853
853
{
854
854
if (!ref -> value ) {
855
855
populate_value (ref );
@@ -900,8 +900,7 @@ static struct ref_array_item *new_ref_array_item(const char *refname,
900
900
* A call-back given to for_each_ref(). Filter refs and keep them for
901
901
* later object processing.
902
902
*/
903
- static int grab_single_ref (const char * refname , const struct object_id * oid ,
904
- int flag , void * cb_data )
903
+ int ref_filter_handler (const char * refname , const struct object_id * oid , int flag , void * cb_data )
905
904
{
906
905
struct ref_filter_cbdata * ref_cbdata = cb_data ;
907
906
struct ref_filter * filter = & ref_cbdata -> filter ;
@@ -947,14 +946,14 @@ void ref_array_clear(struct ref_array *array)
947
946
array -> nr = array -> alloc = 0 ;
948
947
}
949
948
950
- static int cmp_ref_sort (struct ref_sort * s , struct ref_array_item * a , struct ref_array_item * b )
949
+ static int cmp_ref_sorting (struct ref_sorting * s , struct ref_array_item * a , struct ref_array_item * b )
951
950
{
952
951
struct atom_value * va , * vb ;
953
952
int cmp ;
954
953
cmp_type cmp_type = used_atom_type [s -> atom ];
955
954
956
- get_value (a , s -> atom , & va );
957
- get_value (b , s -> atom , & vb );
955
+ get_ref_atom_value (a , s -> atom , & va );
956
+ get_ref_atom_value (b , s -> atom , & vb );
958
957
switch (cmp_type ) {
959
958
case FIELD_STR :
960
959
cmp = strcmp (va -> s , vb -> s );
@@ -971,24 +970,24 @@ static int cmp_ref_sort(struct ref_sort *s, struct ref_array_item *a, struct ref
971
970
return (s -> reverse ) ? - cmp : cmp ;
972
971
}
973
972
974
- static struct ref_sort * ref_sort ;
973
+ static struct ref_sorting * ref_sorting ;
975
974
static int compare_refs (const void * a_ , const void * b_ )
976
975
{
977
976
struct ref_array_item * a = * ((struct ref_array_item * * )a_ );
978
977
struct ref_array_item * b = * ((struct ref_array_item * * )b_ );
979
- struct ref_sort * s ;
978
+ struct ref_sorting * s ;
980
979
981
- for (s = ref_sort ; s ; s = s -> next ) {
982
- int cmp = cmp_ref_sort (s , a , b );
980
+ for (s = ref_sorting ; s ; s = s -> next ) {
981
+ int cmp = cmp_ref_sorting (s , a , b );
983
982
if (cmp )
984
983
return cmp ;
985
984
}
986
985
return 0 ;
987
986
}
988
987
989
- static void sort_refs (struct ref_sort * sort , struct ref_array * array )
988
+ void ref_array_sort (struct ref_sorting * sort , struct ref_array * array )
990
989
{
991
- ref_sort = sort ;
990
+ ref_sorting = sort ;
992
991
qsort (array -> items , array -> nr , sizeof (struct ref_array_item * ), compare_refs );
993
992
}
994
993
@@ -1056,7 +1055,7 @@ static void emit(const char *cp, const char *ep)
1056
1055
}
1057
1056
}
1058
1057
1059
- static void show_ref (struct ref_array_item * info , const char * format , int quote_style )
1058
+ void show_ref_array_item (struct ref_array_item * info , const char * format , int quote_style )
1060
1059
{
1061
1060
const char * cp , * sp , * ep ;
1062
1061
@@ -1066,7 +1065,7 @@ static void show_ref(struct ref_array_item *info, const char *format, int quote_
1066
1065
ep = strchr (sp , ')' );
1067
1066
if (cp < sp )
1068
1067
emit (cp , sp );
1069
- get_value (info , parse_atom (sp + 2 , ep ), & atomv );
1068
+ get_ref_atom_value (info , parse_ref_filter_atom (sp + 2 , ep ), & atomv );
1070
1069
print_value (atomv , quote_style );
1071
1070
}
1072
1071
if (* cp ) {
@@ -1085,21 +1084,22 @@ static void show_ref(struct ref_array_item *info, const char *format, int quote_
1085
1084
putchar ('\n' );
1086
1085
}
1087
1086
1088
- static struct ref_sort * default_sort (void )
1087
+ /* If no sorting option is given, use refname to sort as default */
1088
+ struct ref_sorting * ref_default_sorting (void )
1089
1089
{
1090
1090
static const char cstr_name [] = "refname" ;
1091
1091
1092
- struct ref_sort * sort = xcalloc (1 , sizeof (* sort ));
1092
+ struct ref_sorting * sort = xcalloc (1 , sizeof (* sort ));
1093
1093
1094
1094
sort -> next = NULL ;
1095
- sort -> atom = parse_atom (cstr_name , cstr_name + strlen (cstr_name ));
1095
+ sort -> atom = parse_ref_filter_atom (cstr_name , cstr_name + strlen (cstr_name ));
1096
1096
return sort ;
1097
1097
}
1098
1098
1099
- static int opt_parse_sort (const struct option * opt , const char * arg , int unset )
1099
+ int parse_opt_ref_sorting (const struct option * opt , const char * arg , int unset )
1100
1100
{
1101
- struct ref_sort * * sort_tail = opt -> value ;
1102
- struct ref_sort * s ;
1101
+ struct ref_sorting * * sort_tail = opt -> value ;
1102
+ struct ref_sorting * s ;
1103
1103
int len ;
1104
1104
1105
1105
if (!arg ) /* should --no-sort void the list ? */
@@ -1114,7 +1114,7 @@ static int opt_parse_sort(const struct option *opt, const char *arg, int unset)
1114
1114
arg ++ ;
1115
1115
}
1116
1116
len = strlen (arg );
1117
- s -> atom = parse_atom (arg , arg + len );
1117
+ s -> atom = parse_ref_filter_atom (arg , arg + len );
1118
1118
return 0 ;
1119
1119
}
1120
1120
@@ -1127,7 +1127,7 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)
1127
1127
{
1128
1128
int i ;
1129
1129
const char * format = "%(objectname) %(objecttype)\t%(refname)" ;
1130
- struct ref_sort * sort = NULL , * * sort_tail = & sort ;
1130
+ struct ref_sorting * sort = NULL , * * sort_tail = & sort ;
1131
1131
int maxcount = 0 , quote_style = 0 ;
1132
1132
struct ref_filter_cbdata ref_cbdata ;
1133
1133
@@ -1145,7 +1145,7 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)
1145
1145
OPT_INTEGER ( 0 , "count" , & maxcount , N_ ("show only <n> matched refs" )),
1146
1146
OPT_STRING ( 0 , "format" , & format , N_ ("format" ), N_ ("format to use for the output" )),
1147
1147
OPT_CALLBACK (0 , "sort" , sort_tail , N_ ("key" ),
1148
- N_ ("field name to sort on" ), & opt_parse_sort ),
1148
+ N_ ("field name to sort on" ), & parse_opt_ref_sorting ),
1149
1149
OPT_END (),
1150
1150
};
1151
1151
@@ -1158,25 +1158,25 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)
1158
1158
error ("more than one quoting style?" );
1159
1159
usage_with_options (for_each_ref_usage , opts );
1160
1160
}
1161
- if (verify_format (format ))
1161
+ if (verify_ref_format (format ))
1162
1162
usage_with_options (for_each_ref_usage , opts );
1163
1163
1164
1164
if (!sort )
1165
- sort = default_sort ();
1165
+ sort = ref_default_sorting ();
1166
1166
1167
1167
/* for warn_ambiguous_refs */
1168
1168
git_config (git_default_config , NULL );
1169
1169
1170
1170
memset (& ref_cbdata , 0 , sizeof (ref_cbdata ));
1171
1171
ref_cbdata .filter .name_patterns = argv ;
1172
- for_each_rawref (grab_single_ref , & ref_cbdata );
1172
+ for_each_rawref (ref_filter_handler , & ref_cbdata );
1173
1173
1174
- sort_refs (sort , & ref_cbdata .array );
1174
+ ref_array_sort (sort , & ref_cbdata .array );
1175
1175
1176
1176
if (!maxcount || ref_cbdata .array .nr < maxcount )
1177
1177
maxcount = ref_cbdata .array .nr ;
1178
1178
for (i = 0 ; i < maxcount ; i ++ )
1179
- show_ref (ref_cbdata .array .items [i ], format , quote_style );
1179
+ show_ref_array_item (ref_cbdata .array .items [i ], format , quote_style );
1180
1180
ref_array_clear (& ref_cbdata .array );
1181
1181
return 0 ;
1182
1182
}
0 commit comments