Skip to content

Commit e85fcb3

Browse files
adlternativegitster
authored andcommitted
ref-filter: use non-const ref_format in *_atom_parser()
Use non-const ref_format in *_atom_parser(), which can help us modify the members of ref_format in *_atom_parser(). Mentored-by: Christian Couder <[email protected]> Mentored-by: Hariom Verma <[email protected]> Signed-off-by: ZheNing Hu <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7121c4d commit e85fcb3

File tree

3 files changed

+25
-25
lines changed

3 files changed

+25
-25
lines changed

builtin/tag.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ static int verify_tag(const char *name, const char *ref,
146146
const struct object_id *oid, void *cb_data)
147147
{
148148
int flags;
149-
const struct ref_format *format = cb_data;
149+
struct ref_format *format = cb_data;
150150
flags = GPG_VERIFY_VERBOSE;
151151

152152
if (format->format)

ref-filter.c

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ static int strbuf_addf_ret(struct strbuf *sb, int ret, const char *fmt, ...)
226226
return ret;
227227
}
228228

229-
static int color_atom_parser(const struct ref_format *format, struct used_atom *atom,
229+
static int color_atom_parser(struct ref_format *format, struct used_atom *atom,
230230
const char *color_value, struct strbuf *err)
231231
{
232232
if (!color_value)
@@ -264,7 +264,7 @@ static int refname_atom_parser_internal(struct refname_atom *atom, const char *a
264264
return 0;
265265
}
266266

267-
static int remote_ref_atom_parser(const struct ref_format *format, struct used_atom *atom,
267+
static int remote_ref_atom_parser(struct ref_format *format, struct used_atom *atom,
268268
const char *arg, struct strbuf *err)
269269
{
270270
struct string_list params = STRING_LIST_INIT_DUP;
@@ -311,7 +311,7 @@ static int remote_ref_atom_parser(const struct ref_format *format, struct used_a
311311
return 0;
312312
}
313313

314-
static int objecttype_atom_parser(const struct ref_format *format, struct used_atom *atom,
314+
static int objecttype_atom_parser(struct ref_format *format, struct used_atom *atom,
315315
const char *arg, struct strbuf *err)
316316
{
317317
if (arg)
@@ -323,7 +323,7 @@ static int objecttype_atom_parser(const struct ref_format *format, struct used_a
323323
return 0;
324324
}
325325

326-
static int objectsize_atom_parser(const struct ref_format *format, struct used_atom *atom,
326+
static int objectsize_atom_parser(struct ref_format *format, struct used_atom *atom,
327327
const char *arg, struct strbuf *err)
328328
{
329329
if (!arg) {
@@ -343,7 +343,7 @@ static int objectsize_atom_parser(const struct ref_format *format, struct used_a
343343
return 0;
344344
}
345345

346-
static int deltabase_atom_parser(const struct ref_format *format, struct used_atom *atom,
346+
static int deltabase_atom_parser(struct ref_format *format, struct used_atom *atom,
347347
const char *arg, struct strbuf *err)
348348
{
349349
if (arg)
@@ -355,7 +355,7 @@ static int deltabase_atom_parser(const struct ref_format *format, struct used_at
355355
return 0;
356356
}
357357

358-
static int body_atom_parser(const struct ref_format *format, struct used_atom *atom,
358+
static int body_atom_parser(struct ref_format *format, struct used_atom *atom,
359359
const char *arg, struct strbuf *err)
360360
{
361361
if (arg)
@@ -364,7 +364,7 @@ static int body_atom_parser(const struct ref_format *format, struct used_atom *a
364364
return 0;
365365
}
366366

367-
static int subject_atom_parser(const struct ref_format *format, struct used_atom *atom,
367+
static int subject_atom_parser(struct ref_format *format, struct used_atom *atom,
368368
const char *arg, struct strbuf *err)
369369
{
370370
if (!arg)
@@ -376,7 +376,7 @@ static int subject_atom_parser(const struct ref_format *format, struct used_atom
376376
return 0;
377377
}
378378

379-
static int trailers_atom_parser(const struct ref_format *format, struct used_atom *atom,
379+
static int trailers_atom_parser(struct ref_format *format, struct used_atom *atom,
380380
const char *arg, struct strbuf *err)
381381
{
382382
atom->u.contents.trailer_opts.no_divider = 1;
@@ -402,7 +402,7 @@ static int trailers_atom_parser(const struct ref_format *format, struct used_ato
402402
return 0;
403403
}
404404

405-
static int contents_atom_parser(const struct ref_format *format, struct used_atom *atom,
405+
static int contents_atom_parser(struct ref_format *format, struct used_atom *atom,
406406
const char *arg, struct strbuf *err)
407407
{
408408
if (!arg)
@@ -430,7 +430,7 @@ static int contents_atom_parser(const struct ref_format *format, struct used_ato
430430
return 0;
431431
}
432432

433-
static int raw_atom_parser(const struct ref_format *format, struct used_atom *atom,
433+
static int raw_atom_parser(struct ref_format *format, struct used_atom *atom,
434434
const char *arg, struct strbuf *err)
435435
{
436436
if (!arg)
@@ -442,7 +442,7 @@ static int raw_atom_parser(const struct ref_format *format, struct used_atom *at
442442
return 0;
443443
}
444444

445-
static int oid_atom_parser(const struct ref_format *format, struct used_atom *atom,
445+
static int oid_atom_parser(struct ref_format *format, struct used_atom *atom,
446446
const char *arg, struct strbuf *err)
447447
{
448448
if (!arg)
@@ -461,7 +461,7 @@ static int oid_atom_parser(const struct ref_format *format, struct used_atom *at
461461
return 0;
462462
}
463463

464-
static int person_email_atom_parser(const struct ref_format *format, struct used_atom *atom,
464+
static int person_email_atom_parser(struct ref_format *format, struct used_atom *atom,
465465
const char *arg, struct strbuf *err)
466466
{
467467
if (!arg)
@@ -475,7 +475,7 @@ static int person_email_atom_parser(const struct ref_format *format, struct used
475475
return 0;
476476
}
477477

478-
static int refname_atom_parser(const struct ref_format *format, struct used_atom *atom,
478+
static int refname_atom_parser(struct ref_format *format, struct used_atom *atom,
479479
const char *arg, struct strbuf *err)
480480
{
481481
return refname_atom_parser_internal(&atom->u.refname, arg, atom->name, err);
@@ -492,7 +492,7 @@ static align_type parse_align_position(const char *s)
492492
return -1;
493493
}
494494

495-
static int align_atom_parser(const struct ref_format *format, struct used_atom *atom,
495+
static int align_atom_parser(struct ref_format *format, struct used_atom *atom,
496496
const char *arg, struct strbuf *err)
497497
{
498498
struct align *align = &atom->u.align;
@@ -544,7 +544,7 @@ static int align_atom_parser(const struct ref_format *format, struct used_atom *
544544
return 0;
545545
}
546546

547-
static int if_atom_parser(const struct ref_format *format, struct used_atom *atom,
547+
static int if_atom_parser(struct ref_format *format, struct used_atom *atom,
548548
const char *arg, struct strbuf *err)
549549
{
550550
if (!arg) {
@@ -559,7 +559,7 @@ static int if_atom_parser(const struct ref_format *format, struct used_atom *ato
559559
return 0;
560560
}
561561

562-
static int head_atom_parser(const struct ref_format *format, struct used_atom *atom,
562+
static int head_atom_parser(struct ref_format *format, struct used_atom *atom,
563563
const char *arg, struct strbuf *unused_err)
564564
{
565565
atom->u.head = resolve_refdup("HEAD", RESOLVE_REF_READING, NULL, NULL);
@@ -570,7 +570,7 @@ static struct {
570570
const char *name;
571571
info_source source;
572572
cmp_type cmp_type;
573-
int (*parser)(const struct ref_format *format, struct used_atom *atom,
573+
int (*parser)(struct ref_format *format, struct used_atom *atom,
574574
const char *arg, struct strbuf *err);
575575
} valid_atom[] = {
576576
[ATOM_REFNAME] = { "refname", SOURCE_NONE, FIELD_STR, refname_atom_parser },
@@ -653,7 +653,7 @@ struct atom_value {
653653
/*
654654
* Used to parse format string and sort specifiers
655655
*/
656-
static int parse_ref_filter_atom(const struct ref_format *format,
656+
static int parse_ref_filter_atom(struct ref_format *format,
657657
const char *atom, const char *ep,
658658
struct strbuf *err)
659659
{
@@ -2556,9 +2556,9 @@ static void append_literal(const char *cp, const char *ep, struct ref_formatting
25562556
}
25572557

25582558
int format_ref_array_item(struct ref_array_item *info,
2559-
const struct ref_format *format,
2560-
struct strbuf *final_buf,
2561-
struct strbuf *error_buf)
2559+
struct ref_format *format,
2560+
struct strbuf *final_buf,
2561+
struct strbuf *error_buf)
25622562
{
25632563
const char *cp, *sp, *ep;
25642564
struct ref_formatting_state state = REF_FORMATTING_STATE_INIT;
@@ -2602,7 +2602,7 @@ int format_ref_array_item(struct ref_array_item *info,
26022602
}
26032603

26042604
void pretty_print_ref(const char *name, const struct object_id *oid,
2605-
const struct ref_format *format)
2605+
struct ref_format *format)
26062606
{
26072607
struct ref_array_item *ref_item;
26082608
struct strbuf output = STRBUF_INIT;

ref-filter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ void ref_array_sort(struct ref_sorting *sort, struct ref_array *array);
116116
void ref_sorting_set_sort_flags_all(struct ref_sorting *sorting, unsigned int mask, int on);
117117
/* Based on the given format and quote_style, fill the strbuf */
118118
int format_ref_array_item(struct ref_array_item *info,
119-
const struct ref_format *format,
119+
struct ref_format *format,
120120
struct strbuf *final_buf,
121121
struct strbuf *error_buf);
122122
/* Parse a single sort specifier and add it to the list */
@@ -137,7 +137,7 @@ void setup_ref_filter_porcelain_msg(void);
137137
* name must be a fully qualified refname.
138138
*/
139139
void pretty_print_ref(const char *name, const struct object_id *oid,
140-
const struct ref_format *format);
140+
struct ref_format *format);
141141

142142
/*
143143
* Push a single ref onto the array; this can be used to construct your own

0 commit comments

Comments
 (0)