@@ -45,18 +45,6 @@ static int option_parse_if_missing(const struct option *opt,
return trailer_set_if_missing(opt->value, arg);
}
-static void free_new_trailers(struct list_head *trailers)
-{
- struct list_head *pos, *tmp;
- struct new_trailer_item *item;
-
- list_for_each_safe(pos, tmp, trailers) {
- item = list_entry(pos, struct new_trailer_item, list);
- list_del(pos);
- free(item);
- }
-}
-
static int option_parse_trailer(const struct option *opt,
const char *arg, int unset)
{
@@ -66,6 +66,11 @@ static LIST_HEAD(conf_head);
static char *separators = ":";
+const char *trailer_default_separators(void)
+{
+ return separators;
+}
+
static int configured;
#define TRAILER_ARG_STRING "$ARG"
@@ -424,6 +429,29 @@ int trailer_set_if_missing(enum trailer_if_missing *item, const char *value)
return 0;
}
+void trailer_set_conf_where(enum trailer_where where,
+ struct trailer_conf *conf)
+{
+ conf->where = where;
+}
+
+void trailer_set_conf_if_exists(enum trailer_if_exists if_exists,
+ struct trailer_conf *conf)
+{
+ conf->if_exists = if_exists;
+}
+
+void trailer_set_conf_if_missing(enum trailer_if_missing if_missing,
+ struct trailer_conf *conf)
+{
+ conf->if_missing = if_missing;
+}
+
+struct trailer_conf *new_trailer_conf(void)
+{
+ return xcalloc(1, sizeof(struct trailer_conf));
+}
+
void duplicate_trailer_conf(struct trailer_conf *dst,
const struct trailer_conf *src)
{
@@ -434,6 +462,15 @@ void duplicate_trailer_conf(struct trailer_conf *dst,
dst->cmd = xstrdup_or_null(src->cmd);
}
+void free_trailer_conf(struct trailer_conf *conf)
+{
+ free(conf->name);
+ free(conf->key);
+ free(conf->command);
+ free(conf->cmd);
+ free(conf);
+}
+
static struct arg_item *get_conf_item(const char *name)
{
struct list_head *pos;
@@ -1076,6 +1113,18 @@ void free_trailers(struct list_head *trailers)
}
}
+void free_new_trailers(struct list_head *trailers)
+{
+ struct list_head *pos, *tmp;
+ struct new_trailer_item *item;
+
+ list_for_each_safe(pos, tmp, trailers) {
+ item = list_entry(pos, struct new_trailer_item, list);
+ list_del(pos);
+ free(item);
+ }
+}
+
size_t trailer_block_start(struct trailer_block *trailer_block)
{
return trailer_block->start;
@@ -46,8 +46,14 @@ struct new_trailer_item {
enum trailer_if_missing if_missing;
};
+void trailer_set_conf_where(enum trailer_where, struct trailer_conf *);
+void trailer_set_conf_if_exists(enum trailer_if_exists, struct trailer_conf *);
+void trailer_set_conf_if_missing(enum trailer_if_missing, struct trailer_conf *);
+
+struct trailer_conf *new_trailer_conf(void);
void duplicate_trailer_conf(struct trailer_conf *dst,
const struct trailer_conf *src);
+const char *trailer_default_separators(void);
void trailer_add_arg_item(struct list_head *arg_head, char *tok, char *val,
const struct trailer_conf *conf,
const struct new_trailer_item *new_trailer_item);
@@ -98,6 +104,8 @@ void format_trailers(const struct process_trailer_options *,
struct list_head *trailers,
struct strbuf *out);
void free_trailers(struct list_head *);
+void free_new_trailers(struct list_head *);
+void free_trailer_conf(struct trailer_conf *);
/*
* Convenience function to format the trailers from the commit msg "msg" into