From: ZheNing Hu <adlternative@xxxxxxxxx> parse_ref_filter_atom() checks whether the type of the atom is ATOM_SYMREF, this is not necessary for other atoms. So add the symref_atom_parser() specifically to parse the atom, and set need_symref in it. This can make the program logic more concise. Mentored-by: Christian Couder <christian.couder@xxxxxxxxx> Mentored-by: Hariom Verma <hariom18599@xxxxxxxxx> Signed-off-by: ZheNing Hu <adlternative@xxxxxxxxx> --- ref-filter.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ref-filter.c b/ref-filter.c index bde1f3de9eb..a0de5f21ff5 100644 --- a/ref-filter.c +++ b/ref-filter.c @@ -481,6 +481,13 @@ static int person_email_atom_parser(struct ref_format *format, struct used_atom return 0; } +static int symref_atom_parser(struct ref_format *format, struct used_atom *atom, + const char *arg, struct strbuf *err) +{ + need_symref = 1; + return refname_atom_parser_internal(&atom->u.refname, arg, atom->name, err); +} + static int refname_atom_parser(struct ref_format *format, struct used_atom *atom, const char *arg, struct strbuf *err) { @@ -620,7 +627,7 @@ static struct { [ATOM_RAW] = { "raw", SOURCE_OBJ, FIELD_STR, raw_atom_parser }, [ATOM_UPSTREAM] = { "upstream", SOURCE_NONE, FIELD_STR, remote_ref_atom_parser }, [ATOM_PUSH] = { "push", SOURCE_NONE, FIELD_STR, remote_ref_atom_parser }, - [ATOM_SYMREF] = { "symref", SOURCE_NONE, FIELD_STR, refname_atom_parser }, + [ATOM_SYMREF] = { "symref", SOURCE_NONE, FIELD_STR, symref_atom_parser }, [ATOM_FLAG] = { "flag", SOURCE_NONE }, [ATOM_HEAD] = { "HEAD", SOURCE_NONE, FIELD_STR, head_atom_parser }, [ATOM_COLOR] = { "color", SOURCE_NONE, FIELD_STR, color_atom_parser }, @@ -748,8 +755,6 @@ static int parse_ref_filter_atom(struct ref_format *format, return -1; if (deref) need_tagged = 1; - if (i == ATOM_SYMREF) - need_symref = 1; return at; } -- gitgitgadget