]> git.ipfire.org Git - thirdparty/git.git/blame - pretty.h
refs: print error message in debug output
[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;
90563aed 9struct process_trailer_options;
cf394719
OT
10
11/* Commit formats */
12enum 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,
23
24 CMIT_FMT_UNSPECIFIED
25};
26
96099726
RS
27struct pretty_print_describe_status {
28 unsigned int max_invocations;
29};
30
cf394719
OT
31struct pretty_print_context {
32 /*
33 * Callers should tweak these to change the behavior of pp_* functions.
34 */
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;
19d097e3 51 unsigned encode_email_headers:1;
96099726 52 struct pretty_print_describe_status *describe_status;
cf394719
OT
53
54 /*
55 * Fields below here are manipulated internally by pp_* functions and
56 * should not be counted on by callers.
57 */
58 struct string_list in_body_headers;
59 int graph_width;
60};
61
d0e63260 62/* Check whether commit format is mail. */
cf394719
OT
63static inline int cmit_fmt_is_mail(enum cmit_fmt fmt)
64{
65 return (fmt == CMIT_FMT_EMAIL || fmt == CMIT_FMT_MBOXRD);
66}
67
3c7e2e8f
JK
68/*
69 * Examine the user-specified format given by "fmt" (or if NULL, the global one
70 * previously saved by get_commit_format()), and set flags based on which items
71 * the format will need when it is expanded.
72 */
cf394719
OT
73struct userformat_want {
74 unsigned notes:1;
ad6f028f 75 unsigned source:1;
b2086b51 76 unsigned decorate:1;
cf394719 77};
cf394719 78void userformat_find_requirements(const char *fmt, struct userformat_want *w);
d0e63260
OT
79
80/*
81 * Shortcut for invoking pretty_print_commit if we do not have any context.
82 * Context would be set empty except "fmt".
83 */
cf394719
OT
84void pp_commit_easy(enum cmit_fmt fmt, const struct commit *commit,
85 struct strbuf *sb);
d0e63260
OT
86
87/*
88 * Get information about user and date from "line", format it and
89 * put it into "sb".
90 * Format of "line" must be readable for split_ident_line function.
91 * The resulting format is "what: name <email> date".
92 */
cf394719
OT
93void pp_user_info(struct pretty_print_context *pp, const char *what,
94 struct strbuf *sb, const char *line,
95 const char *encoding);
d0e63260
OT
96
97/*
98 * Format title line of commit message taken from "msg_p" and
99 * put it into "sb".
100 * First line of "msg_p" is also affected.
101 */
cf394719
OT
102void pp_title_line(struct pretty_print_context *pp, const char **msg_p,
103 struct strbuf *sb, const char *encoding,
104 int need_8bit_cte);
d0e63260
OT
105
106/*
107 * Get current state of commit message from "msg_p" and continue formatting
108 * by adding indentation and '>' signs. Put result into "sb".
109 */
cf394719
OT
110void pp_remainder(struct pretty_print_context *pp, const char **msg_p,
111 struct strbuf *sb, int indent);
112
d0e63260
OT
113/*
114 * Create a text message about commit using given "format" and "context".
115 * Put the result to "sb".
116 * Please use this function for custom formats.
117 */
f54fbf5e
SB
118void repo_format_commit_message(struct repository *r,
119 const struct commit *commit,
cf394719
OT
120 const char *format, struct strbuf *sb,
121 const struct pretty_print_context *context);
f54fbf5e
SB
122#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
123#define format_commit_message(c, f, s, con) \
124 repo_format_commit_message(the_repository, c, f, s, con)
125#endif
cf394719 126
d0e63260
OT
127/*
128 * Parse given arguments from "arg", check it for correctness and
129 * fill struct rev_info.
130 */
cf394719
OT
131void get_commit_format(const char *arg, struct rev_info *);
132
d0e63260
OT
133/*
134 * Make a commit message with all rules from given "pp"
135 * and put it into "sb".
136 * Please use this function if you have a context (candidate for "pp").
137 */
cf394719
OT
138void pretty_print_commit(struct pretty_print_context *pp,
139 const struct commit *commit,
140 struct strbuf *sb);
141
d0e63260
OT
142/*
143 * Change line breaks in "msg" to "line_separator" and put it into "sb".
144 * Return "msg" itself.
145 */
cf394719
OT
146const char *format_subject(struct strbuf *sb, const char *msg,
147 const char *line_separator);
148
d0e63260 149/* Check if "cmit_fmt" will produce an empty output. */
cf394719
OT
150int commit_format_is_empty(enum cmit_fmt);
151
47d4676a
HV
152/* Make subject of commit message suitable for filename */
153void format_sanitized_subject(struct strbuf *sb, const char *msg, size_t len);
154
90563aed
HV
155/*
156 * Set values of fields in "struct process_trailer_options"
157 * according to trailers arguments.
158 */
159int format_set_trailers_options(struct process_trailer_options *opts,
160 struct string_list *filter_list,
161 struct strbuf *sepbuf,
162 struct strbuf *kvsepbuf,
636a0aee
HV
163 const char **arg,
164 char **invalid_arg);
90563aed 165
cf394719 166#endif /* PRETTY_H */