Skip to content

Commit 94430d0

Browse files
Linus Arvergitster
authored andcommitted
trailer: split process_command_line_args into separate functions
Previously, process_command_line_args did two things: (1) parse trailers from the configuration, and (2) parse trailers defined on the command line. Separate (1) outside to a new function, parse_trailers_from_config. Rename the remaining logic to parse_trailers_from_command_line_args. Signed-off-by: Linus Arver <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c2a8edf commit 94430d0

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

trailer.c

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -711,30 +711,35 @@ static void add_arg_item(struct list_head *arg_head, char *tok, char *val,
711711
list_add_tail(&new_item->list, arg_head);
712712
}
713713

714-
static void process_command_line_args(struct list_head *arg_head,
715-
struct list_head *new_trailer_head)
714+
static void parse_trailers_from_config(struct list_head *config_head)
716715
{
717716
struct arg_item *item;
718-
struct strbuf tok = STRBUF_INIT;
719-
struct strbuf val = STRBUF_INIT;
720-
const struct conf_info *conf;
721717
struct list_head *pos;
722718

723-
/*
724-
* In command-line arguments, '=' is accepted (in addition to the
725-
* separators that are defined).
726-
*/
727-
char *cl_separators = xstrfmt("=%s", separators);
728-
729719
/* Add an arg item for each configured trailer with a command */
730720
list_for_each(pos, &conf_head) {
731721
item = list_entry(pos, struct arg_item, list);
732722
if (item->conf.command)
733-
add_arg_item(arg_head,
723+
add_arg_item(config_head,
734724
xstrdup(token_from_item(item, NULL)),
735725
xstrdup(""),
736726
&item->conf, NULL);
737727
}
728+
}
729+
730+
static void parse_trailers_from_command_line_args(struct list_head *arg_head,
731+
struct list_head *new_trailer_head)
732+
{
733+
struct strbuf tok = STRBUF_INIT;
734+
struct strbuf val = STRBUF_INIT;
735+
const struct conf_info *conf;
736+
struct list_head *pos;
737+
738+
/*
739+
* In command-line arguments, '=' is accepted (in addition to the
740+
* separators that are defined).
741+
*/
742+
char *cl_separators = xstrfmt("=%s", separators);
738743

739744
/* Add an arg item for each trailer on the command line */
740745
list_for_each(pos, new_trailer_head) {
@@ -1069,8 +1074,11 @@ void process_trailers(const char *file,
10691074

10701075

10711076
if (!opts->only_input) {
1077+
LIST_HEAD(config_head);
10721078
LIST_HEAD(arg_head);
1073-
process_command_line_args(&arg_head, new_trailer_head);
1079+
parse_trailers_from_config(&config_head);
1080+
parse_trailers_from_command_line_args(&arg_head, new_trailer_head);
1081+
list_splice(&config_head, &arg_head);
10741082
process_trailers_lists(&head, &arg_head);
10751083
}
10761084

0 commit comments

Comments
 (0)