14 enum trailer_if_exists {
16 EXISTS_ADD_IF_DIFFERENT_NEIGHBOR,
17 EXISTS_ADD_IF_DIFFERENT,
22 enum trailer_if_missing {
28 int trailer_set_where(enum trailer_where *item, const char *value);
29 int trailer_set_if_exists(enum trailer_if_exists *item, const char *value);
30 int trailer_set_if_missing(enum trailer_if_missing *item, const char *value);
34 * True if there is a blank line before the location pointed to by
37 int blank_line_before_trailer;
40 * Pointers to the start and end of the trailer block found. If there
41 * is no trailer block found, these 2 pointers point to the end of the
44 const char *trailer_start, *trailer_end;
47 * Array of trailers found.
54 * A list that represents newly-added trailers, such as those provided
55 * with the --trailer command line option of git-interpret-trailers.
57 struct new_trailer_item {
58 struct list_head list;
62 enum trailer_where where;
63 enum trailer_if_exists if_exists;
64 enum trailer_if_missing if_missing;
67 struct process_trailer_options {
75 const struct strbuf *separator;
76 int (*filter)(const struct strbuf *, void *);
80 #define PROCESS_TRAILER_OPTIONS_INIT {0}
82 void process_trailers(const char *file,
83 const struct process_trailer_options *opts,
84 struct list_head *new_trailer_head);
86 void trailer_info_get(struct trailer_info *info, const char *str,
87 const struct process_trailer_options *opts);
89 void trailer_info_release(struct trailer_info *info);
92 * Format the trailers from the commit msg "msg" into the strbuf "out".
93 * Note two caveats about "opts":
95 * - this is primarily a helper for pretty.c, and not
96 * all of the flags are supported.
98 * - this differs from process_trailers slightly in that we always format
99 * only the trailer block itself, even if the "only_trailers" option is not
102 void format_trailers_from_commit(struct strbuf *out, const char *msg,
103 const struct process_trailer_options *opts);
106 * An interface for iterating over the trailers found in a particular commit
109 * struct trailer_iterator iter;
110 * trailer_iterator_init(&iter, msg);
111 * while (trailer_iterator_advance(&iter))
112 * ... do something with iter.key and iter.val ...
113 * trailer_iterator_release(&iter);
115 struct trailer_iterator {
120 struct trailer_info info;
125 * Initialize "iter" in preparation for walking over the trailers in the commit
126 * message "msg". The "msg" pointer must remain valid until the iterator is
129 * After initializing, note that key/val will not yet point to any trailer.
130 * Call advance() to parse the first one (if any).
132 void trailer_iterator_init(struct trailer_iterator *iter, const char *msg);
135 * Advance to the next trailer of the iterator. Returns 0 if there is no such
136 * trailer, and 1 otherwise. The key and value of the trailer can be
137 * fetched from the iter->key and iter->value fields (which are valid
138 * only until the next advance).
140 int trailer_iterator_advance(struct trailer_iterator *iter);
143 * Release all resources associated with the trailer iteration.
145 void trailer_iterator_release(struct trailer_iterator *iter);
147 #endif /* TRAILER_H */