5 #include "string-list.h"
9 struct process_trailer_options;
15 CMIT_FMT_DEFAULT = CMIT_FMT_MEDIUM,
27 struct pretty_print_context {
29 * Callers should tweak these to change the behavior of pp_* functions.
33 const char *after_subject;
35 struct date_mode date_mode;
36 unsigned date_mode_explicit:1;
37 int print_email_subject;
38 int expand_tabs_in_log;
41 struct reflog_walk_info *reflog_info;
43 const char *output_encoding;
44 struct string_list *mailmap;
46 struct ident_split *from_ident;
47 unsigned encode_email_headers:1;
50 * Fields below here are manipulated internally by pp_* functions and
51 * should not be counted on by callers.
53 struct string_list in_body_headers;
57 /* Check whether commit format is mail. */
58 static inline int cmit_fmt_is_mail(enum cmit_fmt fmt)
60 return (fmt == CMIT_FMT_EMAIL || fmt == CMIT_FMT_MBOXRD);
63 struct userformat_want {
68 /* Set the flag "w->notes" if there is placeholder %N in "fmt". */
69 void userformat_find_requirements(const char *fmt, struct userformat_want *w);
72 * Shortcut for invoking pretty_print_commit if we do not have any context.
73 * Context would be set empty except "fmt".
75 void pp_commit_easy(enum cmit_fmt fmt, const struct commit *commit,
79 * Get information about user and date from "line", format it and
81 * Format of "line" must be readable for split_ident_line function.
82 * The resulting format is "what: name <email> date".
84 void pp_user_info(struct pretty_print_context *pp, const char *what,
85 struct strbuf *sb, const char *line,
86 const char *encoding);
89 * Format title line of commit message taken from "msg_p" and
91 * First line of "msg_p" is also affected.
93 void pp_title_line(struct pretty_print_context *pp, const char **msg_p,
94 struct strbuf *sb, const char *encoding,
98 * Get current state of commit message from "msg_p" and continue formatting
99 * by adding indentation and '>' signs. Put result into "sb".
101 void pp_remainder(struct pretty_print_context *pp, const char **msg_p,
102 struct strbuf *sb, int indent);
105 * Create a text message about commit using given "format" and "context".
106 * Put the result to "sb".
107 * Please use this function for custom formats.
109 void repo_format_commit_message(struct repository *r,
110 const struct commit *commit,
111 const char *format, struct strbuf *sb,
112 const struct pretty_print_context *context);
113 #ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
114 #define format_commit_message(c, f, s, con) \
115 repo_format_commit_message(the_repository, c, f, s, con)
119 * Parse given arguments from "arg", check it for correctness and
120 * fill struct rev_info.
122 void get_commit_format(const char *arg, struct rev_info *);
125 * Make a commit message with all rules from given "pp"
126 * and put it into "sb".
127 * Please use this function if you have a context (candidate for "pp").
129 void pretty_print_commit(struct pretty_print_context *pp,
130 const struct commit *commit,
134 * Change line breaks in "msg" to "line_separator" and put it into "sb".
135 * Return "msg" itself.
137 const char *format_subject(struct strbuf *sb, const char *msg,
138 const char *line_separator);
140 /* Check if "cmit_fmt" will produce an empty output. */
141 int commit_format_is_empty(enum cmit_fmt);
143 /* Make subject of commit message suitable for filename */
144 void format_sanitized_subject(struct strbuf *sb, const char *msg, size_t len);
147 * Set values of fields in "struct process_trailer_options"
148 * according to trailers arguments.
150 int format_set_trailers_options(struct process_trailer_options *opts,
151 struct string_list *filter_list,
152 struct strbuf *sepbuf,
153 struct strbuf *kvsepbuf,
157 #endif /* PRETTY_H */