5 #include "string-list.h"
14 CMIT_FMT_DEFAULT
= CMIT_FMT_MEDIUM
,
26 struct pretty_print_context
{
28 * Callers should tweak these to change the behavior of pp_* functions.
32 const char *after_subject
;
34 struct date_mode date_mode
;
35 unsigned date_mode_explicit
:1;
36 int print_email_subject
;
37 int expand_tabs_in_log
;
40 struct reflog_walk_info
*reflog_info
;
42 const char *output_encoding
;
43 struct string_list
*mailmap
;
45 struct ident_split
*from_ident
;
48 * Fields below here are manipulated internally by pp_* functions and
49 * should not be counted on by callers.
51 struct string_list in_body_headers
;
55 /* Check whether commit format is mail. */
56 static inline int cmit_fmt_is_mail(enum cmit_fmt fmt
)
58 return (fmt
== CMIT_FMT_EMAIL
|| fmt
== CMIT_FMT_MBOXRD
);
61 struct userformat_want
{
66 /* Set the flag "w->notes" if there is placeholder %N in "fmt". */
67 void userformat_find_requirements(const char *fmt
, struct userformat_want
*w
);
70 * Shortcut for invoking pretty_print_commit if we do not have any context.
71 * Context would be set empty except "fmt".
73 void pp_commit_easy(enum cmit_fmt fmt
, const struct commit
*commit
,
77 * Get information about user and date from "line", format it and
79 * Format of "line" must be readable for split_ident_line function.
80 * The resulting format is "what: name <email> date".
82 void pp_user_info(struct pretty_print_context
*pp
, const char *what
,
83 struct strbuf
*sb
, const char *line
,
84 const char *encoding
);
87 * Format title line of commit message taken from "msg_p" and
89 * First line of "msg_p" is also affected.
91 void pp_title_line(struct pretty_print_context
*pp
, const char **msg_p
,
92 struct strbuf
*sb
, const char *encoding
,
96 * Get current state of commit message from "msg_p" and continue formatting
97 * by adding indentation and '>' signs. Put result into "sb".
99 void pp_remainder(struct pretty_print_context
*pp
, const char **msg_p
,
100 struct strbuf
*sb
, int indent
);
103 * Create a text message about commit using given "format" and "context".
104 * Put the result to "sb".
105 * Please use this function for custom formats.
107 void repo_format_commit_message(struct repository
*r
,
108 const struct commit
*commit
,
109 const char *format
, struct strbuf
*sb
,
110 const struct pretty_print_context
*context
);
111 #ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
112 #define format_commit_message(c, f, s, con) \
113 repo_format_commit_message(the_repository, c, f, s, con)
117 * Parse given arguments from "arg", check it for correctness and
118 * fill struct rev_info.
120 void get_commit_format(const char *arg
, struct rev_info
*);
123 * Make a commit message with all rules from given "pp"
124 * and put it into "sb".
125 * Please use this function if you have a context (candidate for "pp").
127 void pretty_print_commit(struct pretty_print_context
*pp
,
128 const struct commit
*commit
,
132 * Change line breaks in "msg" to "line_separator" and put it into "sb".
133 * Return "msg" itself.
135 const char *format_subject(struct strbuf
*sb
, const char *msg
,
136 const char *line_separator
);
138 /* Check if "cmit_fmt" will produce an empty output. */
139 int commit_format_is_empty(enum cmit_fmt
);
141 #endif /* PRETTY_H */