5 #include "string-list.h"
10 struct process_trailer_options
;
16 CMIT_FMT_DEFAULT
= CMIT_FMT_MEDIUM
,
28 struct pretty_print_describe_status
{
29 unsigned int max_invocations
;
32 struct pretty_print_context
{
34 * Callers should tweak these to change the behavior of pp_* functions.
38 const char *after_subject
;
40 struct date_mode date_mode
;
41 unsigned date_mode_explicit
:1;
42 int print_email_subject
;
43 int expand_tabs_in_log
;
46 struct reflog_walk_info
*reflog_info
;
48 const char *output_encoding
;
49 struct string_list
*mailmap
;
51 struct ident_split
*from_ident
;
52 unsigned encode_email_headers
:1;
53 struct pretty_print_describe_status
*describe_status
;
56 * Fields below here are manipulated internally by pp_* functions and
57 * should not be counted on by callers.
59 struct string_list in_body_headers
;
63 /* Check whether commit format is mail. */
64 static inline int cmit_fmt_is_mail(enum cmit_fmt fmt
)
66 return (fmt
== CMIT_FMT_EMAIL
|| fmt
== CMIT_FMT_MBOXRD
);
70 * Examine the user-specified format given by "fmt" (or if NULL, the global one
71 * previously saved by get_commit_format()), and set flags based on which items
72 * the format will need when it is expanded.
74 struct userformat_want
{
79 void userformat_find_requirements(const char *fmt
, struct userformat_want
*w
);
82 * Shortcut for invoking pretty_print_commit if we do not have any context.
83 * Context would be set empty except "fmt".
85 void pp_commit_easy(enum cmit_fmt fmt
, const struct commit
*commit
,
89 * Get information about user and date from "line", format it and
91 * Format of "line" must be readable for split_ident_line function.
92 * The resulting format is "what: name <email> date".
94 void pp_user_info(struct pretty_print_context
*pp
, const char *what
,
95 struct strbuf
*sb
, const char *line
,
96 const char *encoding
);
99 * Format title line of commit message taken from "msg_p" and
101 * First line of "msg_p" is also affected.
103 void pp_title_line(struct pretty_print_context
*pp
, const char **msg_p
,
104 struct strbuf
*sb
, const char *encoding
,
108 * Get current state of commit message from "msg_p" and continue formatting
109 * by adding indentation and '>' signs. Put result into "sb".
111 void pp_remainder(struct pretty_print_context
*pp
, const char **msg_p
,
112 struct strbuf
*sb
, int indent
);
115 * Create a text message about commit using given "format" and "context".
116 * Put the result to "sb".
117 * Please use this function for custom formats.
119 void repo_format_commit_message(struct repository
*r
,
120 const struct commit
*commit
,
121 const char *format
, struct strbuf
*sb
,
122 const struct pretty_print_context
*context
);
123 #ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
124 #define format_commit_message(c, f, s, con) \
125 repo_format_commit_message(the_repository, c, f, s, con)
129 * Parse given arguments from "arg", check it for correctness and
130 * fill struct rev_info.
132 void get_commit_format(const char *arg
, struct rev_info
*);
135 * Make a commit message with all rules from given "pp"
136 * and put it into "sb".
137 * Please use this function if you have a context (candidate for "pp").
139 void pretty_print_commit(struct pretty_print_context
*pp
,
140 const struct commit
*commit
,
144 * Change line breaks in "msg" to "line_separator" and put it into "sb".
145 * Return "msg" itself.
147 const char *format_subject(struct strbuf
*sb
, const char *msg
,
148 const char *line_separator
);
150 /* Check if "cmit_fmt" will produce an empty output. */
151 int commit_format_is_empty(enum cmit_fmt
);
153 /* Make subject of commit message suitable for filename */
154 void format_sanitized_subject(struct strbuf
*sb
, const char *msg
, size_t len
);
156 int has_non_ascii(const char *text
);
159 * Set values of fields in "struct process_trailer_options"
160 * according to trailers arguments.
162 int format_set_trailers_options(struct process_trailer_options
*opts
,
163 struct string_list
*filter_list
,
164 struct strbuf
*sepbuf
,
165 struct strbuf
*kvsepbuf
,
170 * Like show_date, but pull the timestamp and tz parameters from
171 * the ident_split. It will also sanity-check the values and produce
172 * a well-known sentinel date if they appear bogus.
174 const char *show_ident_date(const struct ident_split
*id
,
175 const struct date_mode
*mode
);
178 #endif /* PRETTY_H */