]> git.ipfire.org Git - thirdparty/git.git/blame - pretty.h
Merge branch 'jt/t5500-unflake'
[thirdparty/git.git] / pretty.h
CommitLineData
cf394719
OT
1#ifndef PRETTY_H
2#define PRETTY_H
3
ef3ca954
EN
4#include "cache.h"
5#include "string-list.h"
6
cf394719 7struct commit;
ef3ca954 8struct strbuf;
cf394719
OT
9
10/* Commit formats */
11enum cmit_fmt {
12 CMIT_FMT_RAW,
13 CMIT_FMT_MEDIUM,
14 CMIT_FMT_DEFAULT = CMIT_FMT_MEDIUM,
15 CMIT_FMT_SHORT,
16 CMIT_FMT_FULL,
17 CMIT_FMT_FULLER,
18 CMIT_FMT_ONELINE,
19 CMIT_FMT_EMAIL,
20 CMIT_FMT_MBOXRD,
21 CMIT_FMT_USERFORMAT,
22
23 CMIT_FMT_UNSPECIFIED
24};
25
26struct pretty_print_context {
27 /*
28 * Callers should tweak these to change the behavior of pp_* functions.
29 */
30 enum cmit_fmt fmt;
31 int abbrev;
32 const char *after_subject;
33 int preserve_subject;
34 struct date_mode date_mode;
35 unsigned date_mode_explicit:1;
36 int print_email_subject;
37 int expand_tabs_in_log;
38 int need_8bit_cte;
39 char *notes_message;
40 struct reflog_walk_info *reflog_info;
41 struct rev_info *rev;
42 const char *output_encoding;
43 struct string_list *mailmap;
44 int color;
45 struct ident_split *from_ident;
19d097e3 46 unsigned encode_email_headers:1;
cf394719
OT
47
48 /*
49 * Fields below here are manipulated internally by pp_* functions and
50 * should not be counted on by callers.
51 */
52 struct string_list in_body_headers;
53 int graph_width;
54};
55
d0e63260 56/* Check whether commit format is mail. */
cf394719
OT
57static inline int cmit_fmt_is_mail(enum cmit_fmt fmt)
58{
59 return (fmt == CMIT_FMT_EMAIL || fmt == CMIT_FMT_MBOXRD);
60}
61
62struct userformat_want {
63 unsigned notes:1;
ad6f028f 64 unsigned source:1;
cf394719
OT
65};
66
d0e63260 67/* Set the flag "w->notes" if there is placeholder %N in "fmt". */
cf394719 68void userformat_find_requirements(const char *fmt, struct userformat_want *w);
d0e63260
OT
69
70/*
71 * Shortcut for invoking pretty_print_commit if we do not have any context.
72 * Context would be set empty except "fmt".
73 */
cf394719
OT
74void pp_commit_easy(enum cmit_fmt fmt, const struct commit *commit,
75 struct strbuf *sb);
d0e63260
OT
76
77/*
78 * Get information about user and date from "line", format it and
79 * put it into "sb".
80 * Format of "line" must be readable for split_ident_line function.
81 * The resulting format is "what: name <email> date".
82 */
cf394719
OT
83void pp_user_info(struct pretty_print_context *pp, const char *what,
84 struct strbuf *sb, const char *line,
85 const char *encoding);
d0e63260
OT
86
87/*
88 * Format title line of commit message taken from "msg_p" and
89 * put it into "sb".
90 * First line of "msg_p" is also affected.
91 */
cf394719
OT
92void pp_title_line(struct pretty_print_context *pp, const char **msg_p,
93 struct strbuf *sb, const char *encoding,
94 int need_8bit_cte);
d0e63260
OT
95
96/*
97 * Get current state of commit message from "msg_p" and continue formatting
98 * by adding indentation and '>' signs. Put result into "sb".
99 */
cf394719
OT
100void pp_remainder(struct pretty_print_context *pp, const char **msg_p,
101 struct strbuf *sb, int indent);
102
d0e63260
OT
103/*
104 * Create a text message about commit using given "format" and "context".
105 * Put the result to "sb".
106 * Please use this function for custom formats.
107 */
f54fbf5e
SB
108void repo_format_commit_message(struct repository *r,
109 const struct commit *commit,
cf394719
OT
110 const char *format, struct strbuf *sb,
111 const struct pretty_print_context *context);
f54fbf5e
SB
112#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
113#define format_commit_message(c, f, s, con) \
114 repo_format_commit_message(the_repository, c, f, s, con)
115#endif
cf394719 116
d0e63260
OT
117/*
118 * Parse given arguments from "arg", check it for correctness and
119 * fill struct rev_info.
120 */
cf394719
OT
121void get_commit_format(const char *arg, struct rev_info *);
122
d0e63260
OT
123/*
124 * Make a commit message with all rules from given "pp"
125 * and put it into "sb".
126 * Please use this function if you have a context (candidate for "pp").
127 */
cf394719
OT
128void pretty_print_commit(struct pretty_print_context *pp,
129 const struct commit *commit,
130 struct strbuf *sb);
131
d0e63260
OT
132/*
133 * Change line breaks in "msg" to "line_separator" and put it into "sb".
134 * Return "msg" itself.
135 */
cf394719
OT
136const char *format_subject(struct strbuf *sb, const char *msg,
137 const char *line_separator);
138
d0e63260 139/* Check if "cmit_fmt" will produce an empty output. */
cf394719
OT
140int commit_format_is_empty(enum cmit_fmt);
141
142#endif /* PRETTY_H */