]>
Commit | Line | Data |
---|---|---|
b1d78d77 CC |
1 | #ifndef TRAILER_H |
2 | #define TRAILER_H | |
3 | ||
51166b87 PB |
4 | #include "list.h" |
5 | ||
ef3ca954 EN |
6 | struct strbuf; |
7 | ||
52fc319d | 8 | enum trailer_where { |
0ea5292e | 9 | WHERE_DEFAULT, |
52fc319d PB |
10 | WHERE_END, |
11 | WHERE_AFTER, | |
12 | WHERE_BEFORE, | |
13 | WHERE_START | |
14 | }; | |
15 | enum trailer_if_exists { | |
0ea5292e | 16 | EXISTS_DEFAULT, |
52fc319d PB |
17 | EXISTS_ADD_IF_DIFFERENT_NEIGHBOR, |
18 | EXISTS_ADD_IF_DIFFERENT, | |
19 | EXISTS_ADD, | |
20 | EXISTS_REPLACE, | |
21 | EXISTS_DO_NOTHING | |
22 | }; | |
23 | enum trailer_if_missing { | |
0ea5292e | 24 | MISSING_DEFAULT, |
52fc319d PB |
25 | MISSING_ADD, |
26 | MISSING_DO_NOTHING | |
27 | }; | |
28 | ||
29 | int trailer_set_where(enum trailer_where *item, const char *value); | |
30 | int trailer_set_if_exists(enum trailer_if_exists *item, const char *value); | |
31 | int trailer_set_if_missing(enum trailer_if_missing *item, const char *value); | |
32 | ||
e8c352c3 JT |
33 | struct trailer_info { |
34 | /* | |
35 | * True if there is a blank line before the location pointed to by | |
36 | * trailer_start. | |
37 | */ | |
38 | int 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 | */ | |
45 | const char *trailer_start, *trailer_end; | |
46 | ||
47 | /* | |
48 | * Array of trailers found. | |
49 | */ | |
50 | char **trailers; | |
51 | size_t trailer_nr; | |
52 | }; | |
53 | ||
51166b87 PB |
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 | */ | |
58 | struct new_trailer_item { | |
59 | struct list_head list; | |
60 | ||
61 | const char *text; | |
0ea5292e PB |
62 | |
63 | enum trailer_where where; | |
64 | enum trailer_if_exists if_exists; | |
65 | enum trailer_if_missing if_missing; | |
51166b87 PB |
66 | }; |
67 | ||
8abc8980 JK |
68 | struct process_trailer_options { |
69 | int in_place; | |
70 | int trim_empty; | |
56c493ed | 71 | int only_trailers; |
fdbdb64f | 72 | int only_input; |
00002396 | 73 | int unfold; |
1688c9a4 | 74 | int no_divider; |
d9b936db | 75 | int value_only; |
0b691d86 | 76 | const struct strbuf *separator; |
250bea0c AW |
77 | int (*filter)(const struct strbuf *, void *); |
78 | void *filter_data; | |
8abc8980 JK |
79 | }; |
80 | ||
81 | #define PROCESS_TRAILER_OPTIONS_INIT {0} | |
82 | ||
83 | void process_trailers(const char *file, | |
84 | const struct process_trailer_options *opts, | |
51166b87 | 85 | struct list_head *new_trailer_head); |
b1d78d77 | 86 | |
00a21f5c JK |
87 | void trailer_info_get(struct trailer_info *info, const char *str, |
88 | const struct process_trailer_options *opts); | |
e8c352c3 JT |
89 | |
90 | void trailer_info_release(struct trailer_info *info); | |
91 | ||
a388b10f JK |
92 | /* |
93 | * Format the trailers from the commit msg "msg" into the strbuf "out". | |
94 | * Note two caveats about "opts": | |
95 | * | |
96 | * - this is primarily a helper for pretty.c, and not | |
97 | * all of the flags are supported. | |
98 | * | |
99 | * - this differs from process_trailers slightly in that we always format | |
100 | * only the trailer block itself, even if the "only_trailers" option is not | |
101 | * set. | |
102 | */ | |
103 | void format_trailers_from_commit(struct strbuf *out, const char *msg, | |
104 | const struct process_trailer_options *opts); | |
105 | ||
b1d78d77 | 106 | #endif /* TRAILER_H */ |