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 <christian.couder@gmail.com> Mentored-by: Hariom Verma <hariom18599@gmail.com> Signed-off-by: ZheNing Hu <adlternative@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

ZheNing Hu committed Jul 26, 2021 at 03:26 UTC e85fcb355a38b5f01493efecdf0150a10ee471da
3 files changed +25 -25
builtin/tag.c
+1 -1
@@ -146,7 +146,7 @@ static int verify_tag(const char *name, const char *ref,
146 const struct object_id *oid, void *cb_data)
147 {
148 int flags;
149 - const struct ref_format *format = cb_data;
149 + struct ref_format *format = cb_data;
150 flags = GPG_VERIFY_VERBOSE;
151
152 if (format->format)
ref-filter.c
+22 -22
@@ -226,7 +226,7 @@ static int strbuf_addf_ret(struct strbuf *sb, int ret, const char *fmt, ...)
226 return ret;
227 }
228
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,
230 const char *color_value, struct strbuf *err)
231 {
232 if (!color_value)
@@ -264,7 +264,7 @@ static int refname_atom_parser_internal(struct refname_atom *atom, const char *a
264 return 0;
265 }
266
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,
268 const char *arg, struct strbuf *err)
269 {
270 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
311 return 0;
312 }
313
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,
315 const char *arg, struct strbuf *err)
316 {
317 if (arg)
@@ -323,7 +323,7 @@ static int objecttype_atom_parser(const struct ref_format *format, struct used_a
323 return 0;
324 }
325
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,
327 const char *arg, struct strbuf *err)
328 {
329 if (!arg) {
@@ -343,7 +343,7 @@ static int objectsize_atom_parser(const struct ref_format *format, struct used_a
343 return 0;
344 }
345
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,
347 const char *arg, struct strbuf *err)
348 {
349 if (arg)
@@ -355,7 +355,7 @@ static int deltabase_atom_parser(const struct ref_format *format, struct used_at
355 return 0;
356 }
357
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,
359 const char *arg, struct strbuf *err)
360 {
361 if (arg)
@@ -364,7 +364,7 @@ static int body_atom_parser(const struct ref_format *format, struct used_atom *a
364 return 0;
365 }
366
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,
368 const char *arg, struct strbuf *err)
369 {
370 if (!arg)
@@ -376,7 +376,7 @@ static int subject_atom_parser(const struct ref_format *format, struct used_atom
376 return 0;
377 }
378
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,
380 const char *arg, struct strbuf *err)
381 {
382 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
402 return 0;
403 }
404
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,
406 const char *arg, struct strbuf *err)
407 {
408 if (!arg)
@@ -430,7 +430,7 @@ static int contents_atom_parser(const struct ref_format *format, struct used_ato
430 return 0;
431 }
432
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,
434 const char *arg, struct strbuf *err)
435 {
436 if (!arg)
@@ -442,7 +442,7 @@ static int raw_atom_parser(const struct ref_format *format, struct used_atom *at
442 return 0;
443 }
444
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,
446 const char *arg, struct strbuf *err)
447 {
448 if (!arg)
@@ -461,7 +461,7 @@ static int oid_atom_parser(const struct ref_format *format, struct used_atom *at
461 return 0;
462 }
463
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,
465 const char *arg, struct strbuf *err)
466 {
467 if (!arg)
@@ -475,7 +475,7 @@ static int person_email_atom_parser(const struct ref_format *format, struct used
475 return 0;
476 }
477
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,
479 const char *arg, struct strbuf *err)
480 {
481 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)
492 return -1;
493 }
494
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,
496 const char *arg, struct strbuf *err)
497 {
498 struct align *align = &atom->u.align;
@@ -544,7 +544,7 @@ static int align_atom_parser(const struct ref_format *format, struct used_atom *
544 return 0;
545 }
546
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,
548 const char *arg, struct strbuf *err)
549 {
550 if (!arg) {
@@ -559,7 +559,7 @@ static int if_atom_parser(const struct ref_format *format, struct used_atom *ato
559 return 0;
560 }
561
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,
563 const char *arg, struct strbuf *unused_err)
564 {
565 atom->u.head = resolve_refdup("HEAD", RESOLVE_REF_READING, NULL, NULL);
@@ -570,7 +570,7 @@ static struct {
570 const char *name;
571 info_source source;
572 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,
574 const char *arg, struct strbuf *err);
575 } valid_atom[] = {
576 [ATOM_REFNAME] = { "refname", SOURCE_NONE, FIELD_STR, refname_atom_parser },
@@ -653,7 +653,7 @@ struct atom_value {
653 /*
654 * Used to parse format string and sort specifiers
655 */
656 -static int parse_ref_filter_atom(const struct ref_format *format,
656 +static int parse_ref_filter_atom(struct ref_format *format,
657 const char *atom, const char *ep,
658 struct strbuf *err)
659 {
@@ -2556,9 +2556,9 @@ static void append_literal(const char *cp, const char *ep, struct ref_formatting
2556 }
2557
2558 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)
2562 {
2563 const char *cp, *sp, *ep;
2564 struct ref_formatting_state state = REF_FORMATTING_STATE_INIT;
@@ -2602,7 +2602,7 @@ int format_ref_array_item(struct ref_array_item *info,
2602 }
2603
2604 void pretty_print_ref(const char *name, const struct object_id *oid,
2605 - const struct ref_format *format)
2605 + struct ref_format *format)
2606 {
2607 struct ref_array_item *ref_item;
2608 struct strbuf output = STRBUF_INIT;
ref-filter.h
+2 -2
@@ -116,7 +116,7 @@ void ref_array_sort(struct ref_sorting *sort, struct ref_array *array);
116 void ref_sorting_set_sort_flags_all(struct ref_sorting *sorting, unsigned int mask, int on);
117 /* Based on the given format and quote_style, fill the strbuf */
118 int format_ref_array_item(struct ref_array_item *info,
119 - const struct ref_format *format,
119 + struct ref_format *format,
120 struct strbuf *final_buf,
121 struct strbuf *error_buf);
122 /* Parse a single sort specifier and add it to the list */
@@ -137,7 +137,7 @@ void setup_ref_filter_porcelain_msg(void);
137 * name must be a fully qualified refname.
138 */
139 void pretty_print_ref(const char *name, const struct object_id *oid,
140 - const struct ref_format *format);
140 + struct ref_format *format);
141
142 /*
143 * Push a single ref onto the array; this can be used to construct your own