Skip to content

Commit 3ccb4c5

Browse files
peffgitster
authored andcommitted
format-patch: use OPT_STRING_LIST for to/cc options
The to_callback() and cc_callback() functions are identical to the generic parse_opt_string_list() function (except that they don't handle optional arguments, but that's OK because their callers do not use the OPTARG flag). Let's simplify the code by using OPT_STRING_LIST. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7fa7011 commit 3ccb4c5

File tree

1 file changed

+2
-20
lines changed

1 file changed

+2
-20
lines changed

builtin/log.c

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1567,24 +1567,6 @@ static int header_callback(const struct option *opt, const char *arg, int unset)
15671567
return 0;
15681568
}
15691569

1570-
static int to_callback(const struct option *opt, const char *arg, int unset)
1571-
{
1572-
if (unset)
1573-
string_list_clear(&extra_to, 0);
1574-
else
1575-
string_list_append(&extra_to, arg);
1576-
return 0;
1577-
}
1578-
1579-
static int cc_callback(const struct option *opt, const char *arg, int unset)
1580-
{
1581-
if (unset)
1582-
string_list_clear(&extra_cc, 0);
1583-
else
1584-
string_list_append(&extra_cc, arg);
1585-
return 0;
1586-
}
1587-
15881570
static int from_callback(const struct option *opt, const char *arg, int unset)
15891571
{
15901572
char **from = opt->value;
@@ -1957,8 +1939,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
19571939
OPT_GROUP(N_("Messaging")),
19581940
OPT_CALLBACK(0, "add-header", NULL, N_("header"),
19591941
N_("add email header"), header_callback),
1960-
OPT_CALLBACK(0, "to", NULL, N_("email"), N_("add To: header"), to_callback),
1961-
OPT_CALLBACK(0, "cc", NULL, N_("email"), N_("add Cc: header"), cc_callback),
1942+
OPT_STRING_LIST(0, "to", &extra_to, N_("email"), N_("add To: header")),
1943+
OPT_STRING_LIST(0, "cc", &extra_cc, N_("email"), N_("add Cc: header")),
19621944
OPT_CALLBACK_F(0, "from", &from, N_("ident"),
19631945
N_("set From address to <ident> (or committer ident if absent)"),
19641946
PARSE_OPT_OPTARG, from_callback),

0 commit comments

Comments
 (0)