1#ifndef TRAILER_H 2#define TRAILER_H 3 4#include"list.h" 5 6struct strbuf; 7 8enum trailer_where { 9 WHERE_DEFAULT, 10 WHERE_END, 11 WHERE_AFTER, 12 WHERE_BEFORE, 13 WHERE_START 14}; 15enum trailer_if_exists { 16 EXISTS_DEFAULT, 17 EXISTS_ADD_IF_DIFFERENT_NEIGHBOR, 18 EXISTS_ADD_IF_DIFFERENT, 19 EXISTS_ADD, 20 EXISTS_REPLACE, 21 EXISTS_DO_NOTHING 22}; 23enum trailer_if_missing { 24 MISSING_DEFAULT, 25 MISSING_ADD, 26 MISSING_DO_NOTHING 27}; 28 29inttrailer_set_where(enum trailer_where *item,const char*value); 30inttrailer_set_if_exists(enum trailer_if_exists *item,const char*value); 31inttrailer_set_if_missing(enum trailer_if_missing *item,const char*value); 32 33struct trailer_info { 34/* 35 * True if there is a blank line before the location pointed to by 36 * trailer_start. 37 */ 38int blank_line_before_trailer; 39 40/* 41 * Pointers to the start and end of the trailer block found. If there 42 * is no trailer block found, these 2 pointers point to the end of the 43 * input string. 44 */ 45const char*trailer_start, *trailer_end; 46 47/* 48 * Array of trailers found. 49 */ 50char**trailers; 51size_t trailer_nr; 52}; 53 54/* 55 * A list that represents newly-added trailers, such as those provided 56 * with the --trailer command line option of git-interpret-trailers. 57 */ 58struct new_trailer_item { 59struct list_head list; 60 61const char*text; 62 63enum trailer_where where; 64enum trailer_if_exists if_exists; 65enum trailer_if_missing if_missing; 66}; 67 68struct process_trailer_options { 69int in_place; 70int trim_empty; 71int only_trailers; 72int only_input; 73int unfold; 74int no_divider; 75}; 76 77#define PROCESS_TRAILER_OPTIONS_INIT {0} 78 79voidprocess_trailers(const char*file, 80const struct process_trailer_options *opts, 81struct list_head *new_trailer_head); 82 83voidtrailer_info_get(struct trailer_info *info,const char*str, 84const struct process_trailer_options *opts); 85 86voidtrailer_info_release(struct trailer_info *info); 87 88/* 89 * Format the trailers from the commit msg "msg" into the strbuf "out". 90 * Note two caveats about "opts": 91 * 92 * - this is primarily a helper for pretty.c, and not 93 * all of the flags are supported. 94 * 95 * - this differs from process_trailers slightly in that we always format 96 * only the trailer block itself, even if the "only_trailers" option is not 97 * set. 98 */ 99voidformat_trailers_from_commit(struct strbuf *out,const char*msg, 100const struct process_trailer_options *opts); 101 102#endif/* TRAILER_H */