trailers: introduce struct new_trailer_item
[git/git.git] / trailer.h
CommitLineData
b1d78d77
CC
1#ifndef TRAILER_H
2#define TRAILER_H
3
51166b87
PB
4#include "list.h"
5
52fc319d
PB
6enum trailer_where {
7 WHERE_END,
8 WHERE_AFTER,
9 WHERE_BEFORE,
10 WHERE_START
11};
12enum trailer_if_exists {
13 EXISTS_ADD_IF_DIFFERENT_NEIGHBOR,
14 EXISTS_ADD_IF_DIFFERENT,
15 EXISTS_ADD,
16 EXISTS_REPLACE,
17 EXISTS_DO_NOTHING
18};
19enum trailer_if_missing {
20 MISSING_ADD,
21 MISSING_DO_NOTHING
22};
23
24int trailer_set_where(enum trailer_where *item, const char *value);
25int trailer_set_if_exists(enum trailer_if_exists *item, const char *value);
26int trailer_set_if_missing(enum trailer_if_missing *item, const char *value);
27
e8c352c3
JT
28struct trailer_info {
29 /*
30 * True if there is a blank line before the location pointed to by
31 * trailer_start.
32 */
33 int blank_line_before_trailer;
34
35 /*
36 * Pointers to the start and end of the trailer block found. If there
37 * is no trailer block found, these 2 pointers point to the end of the
38 * input string.
39 */
40 const char *trailer_start, *trailer_end;
41
42 /*
43 * Array of trailers found.
44 */
45 char **trailers;
46 size_t trailer_nr;
47};
48
51166b87
PB
49/*
50 * A list that represents newly-added trailers, such as those provided
51 * with the --trailer command line option of git-interpret-trailers.
52 */
53struct new_trailer_item {
54 struct list_head list;
55
56 const char *text;
57};
58
e1f89863 59void process_trailers(const char *file, int in_place, int trim_empty,
51166b87 60 struct list_head *new_trailer_head);
b1d78d77 61
e8c352c3
JT
62void trailer_info_get(struct trailer_info *info, const char *str);
63
64void trailer_info_release(struct trailer_info *info);
65
b1d78d77 66#endif /* TRAILER_H */