format: create pretty.h file
[git/git.git] / pretty.h
CommitLineData
cf394719
OT
1#ifndef PRETTY_H
2#define PRETTY_H
3
4struct commit;
5
6/* Commit formats */
7enum cmit_fmt {
8 CMIT_FMT_RAW,
9 CMIT_FMT_MEDIUM,
10 CMIT_FMT_DEFAULT = CMIT_FMT_MEDIUM,
11 CMIT_FMT_SHORT,
12 CMIT_FMT_FULL,
13 CMIT_FMT_FULLER,
14 CMIT_FMT_ONELINE,
15 CMIT_FMT_EMAIL,
16 CMIT_FMT_MBOXRD,
17 CMIT_FMT_USERFORMAT,
18
19 CMIT_FMT_UNSPECIFIED
20};
21
22struct pretty_print_context {
23 /*
24 * Callers should tweak these to change the behavior of pp_* functions.
25 */
26 enum cmit_fmt fmt;
27 int abbrev;
28 const char *after_subject;
29 int preserve_subject;
30 struct date_mode date_mode;
31 unsigned date_mode_explicit:1;
32 int print_email_subject;
33 int expand_tabs_in_log;
34 int need_8bit_cte;
35 char *notes_message;
36 struct reflog_walk_info *reflog_info;
37 struct rev_info *rev;
38 const char *output_encoding;
39 struct string_list *mailmap;
40 int color;
41 struct ident_split *from_ident;
42
43 /*
44 * Fields below here are manipulated internally by pp_* functions and
45 * should not be counted on by callers.
46 */
47 struct string_list in_body_headers;
48 int graph_width;
49};
50
51static inline int cmit_fmt_is_mail(enum cmit_fmt fmt)
52{
53 return (fmt == CMIT_FMT_EMAIL || fmt == CMIT_FMT_MBOXRD);
54}
55
56struct userformat_want {
57 unsigned notes:1;
58};
59
60void userformat_find_requirements(const char *fmt, struct userformat_want *w);
61void pp_commit_easy(enum cmit_fmt fmt, const struct commit *commit,
62 struct strbuf *sb);
63void pp_user_info(struct pretty_print_context *pp, const char *what,
64 struct strbuf *sb, const char *line,
65 const char *encoding);
66void pp_title_line(struct pretty_print_context *pp, const char **msg_p,
67 struct strbuf *sb, const char *encoding,
68 int need_8bit_cte);
69void pp_remainder(struct pretty_print_context *pp, const char **msg_p,
70 struct strbuf *sb, int indent);
71
72void format_commit_message(const struct commit *commit,
73 const char *format, struct strbuf *sb,
74 const struct pretty_print_context *context);
75
76void get_commit_format(const char *arg, struct rev_info *);
77
78void pretty_print_commit(struct pretty_print_context *pp,
79 const struct commit *commit,
80 struct strbuf *sb);
81
82const char *format_subject(struct strbuf *sb, const char *msg,
83 const char *line_separator);
84
85int commit_format_is_empty(enum cmit_fmt);
86
87#endif /* PRETTY_H */