is_promisor_object(): fix use-after-free of tree buffer
[alt-git.git] / pretty.h
blobf034609e4db6e68efb24a149c580fc7bda3c4cfa
1 #ifndef PRETTY_H
2 #define PRETTY_H
4 #include "cache.h"
5 #include "string-list.h"
7 struct commit;
8 struct strbuf;
9 struct process_trailer_options;
11 /* Commit formats */
12 enum cmit_fmt {
13 CMIT_FMT_RAW,
14 CMIT_FMT_MEDIUM,
15 CMIT_FMT_DEFAULT = CMIT_FMT_MEDIUM,
16 CMIT_FMT_SHORT,
17 CMIT_FMT_FULL,
18 CMIT_FMT_FULLER,
19 CMIT_FMT_ONELINE,
20 CMIT_FMT_EMAIL,
21 CMIT_FMT_MBOXRD,
22 CMIT_FMT_USERFORMAT,
24 CMIT_FMT_UNSPECIFIED
27 struct pretty_print_describe_status {
28 unsigned int max_invocations;
31 struct pretty_print_context {
33 * Callers should tweak these to change the behavior of pp_* functions.
35 enum cmit_fmt fmt;
36 int abbrev;
37 const char *after_subject;
38 int preserve_subject;
39 struct date_mode date_mode;
40 unsigned date_mode_explicit:1;
41 int print_email_subject;
42 int expand_tabs_in_log;
43 int need_8bit_cte;
44 char *notes_message;
45 struct reflog_walk_info *reflog_info;
46 struct rev_info *rev;
47 const char *output_encoding;
48 struct string_list *mailmap;
49 int color;
50 struct ident_split *from_ident;
51 unsigned encode_email_headers:1;
52 struct pretty_print_describe_status *describe_status;
55 * Fields below here are manipulated internally by pp_* functions and
56 * should not be counted on by callers.
58 struct string_list in_body_headers;
59 int graph_width;
62 /* Check whether commit format is mail. */
63 static inline int cmit_fmt_is_mail(enum cmit_fmt fmt)
65 return (fmt == CMIT_FMT_EMAIL || fmt == CMIT_FMT_MBOXRD);
68 struct userformat_want {
69 unsigned notes:1;
70 unsigned source:1;
73 /* Set the flag "w->notes" if there is placeholder %N in "fmt". */
74 void userformat_find_requirements(const char *fmt, struct userformat_want *w);
77 * Shortcut for invoking pretty_print_commit if we do not have any context.
78 * Context would be set empty except "fmt".
80 void pp_commit_easy(enum cmit_fmt fmt, const struct commit *commit,
81 struct strbuf *sb);
84 * Get information about user and date from "line", format it and
85 * put it into "sb".
86 * Format of "line" must be readable for split_ident_line function.
87 * The resulting format is "what: name <email> date".
89 void pp_user_info(struct pretty_print_context *pp, const char *what,
90 struct strbuf *sb, const char *line,
91 const char *encoding);
94 * Format title line of commit message taken from "msg_p" and
95 * put it into "sb".
96 * First line of "msg_p" is also affected.
98 void pp_title_line(struct pretty_print_context *pp, const char **msg_p,
99 struct strbuf *sb, const char *encoding,
100 int need_8bit_cte);
103 * Get current state of commit message from "msg_p" and continue formatting
104 * by adding indentation and '>' signs. Put result into "sb".
106 void pp_remainder(struct pretty_print_context *pp, const char **msg_p,
107 struct strbuf *sb, int indent);
110 * Create a text message about commit using given "format" and "context".
111 * Put the result to "sb".
112 * Please use this function for custom formats.
114 void repo_format_commit_message(struct repository *r,
115 const struct commit *commit,
116 const char *format, struct strbuf *sb,
117 const struct pretty_print_context *context);
118 #ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
119 #define format_commit_message(c, f, s, con) \
120 repo_format_commit_message(the_repository, c, f, s, con)
121 #endif
124 * Parse given arguments from "arg", check it for correctness and
125 * fill struct rev_info.
127 void get_commit_format(const char *arg, struct rev_info *);
130 * Make a commit message with all rules from given "pp"
131 * and put it into "sb".
132 * Please use this function if you have a context (candidate for "pp").
134 void pretty_print_commit(struct pretty_print_context *pp,
135 const struct commit *commit,
136 struct strbuf *sb);
139 * Change line breaks in "msg" to "line_separator" and put it into "sb".
140 * Return "msg" itself.
142 const char *format_subject(struct strbuf *sb, const char *msg,
143 const char *line_separator);
145 /* Check if "cmit_fmt" will produce an empty output. */
146 int commit_format_is_empty(enum cmit_fmt);
148 /* Make subject of commit message suitable for filename */
149 void format_sanitized_subject(struct strbuf *sb, const char *msg, size_t len);
152 * Set values of fields in "struct process_trailer_options"
153 * according to trailers arguments.
155 int format_set_trailers_options(struct process_trailer_options *opts,
156 struct string_list *filter_list,
157 struct strbuf *sepbuf,
158 struct strbuf *kvsepbuf,
159 const char **arg,
160 char **invalid_arg);
162 #endif /* PRETTY_H */