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