git-completion.bash: rename to $__git_cmd_idx
[alt-git.git] / pretty.h
blobd902cdd70a956c39bf319b9f027a6a73a4c173ef
1 #ifndef PRETTY_H
2 #define PRETTY_H
4 #include "cache.h"
5 #include "string-list.h"
7 struct commit;
8 struct strbuf;
9 struct process_trailer_options;
11 /* Commit formats */
12 enum 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,
24 CMIT_FMT_UNSPECIFIED
27 struct pretty_print_context {
29 * Callers should tweak these to change the behavior of pp_* functions.
31 enum cmit_fmt fmt;
32 int abbrev;
33 const char *after_subject;
34 int preserve_subject;
35 struct date_mode date_mode;
36 unsigned date_mode_explicit:1;
37 int print_email_subject;
38 int expand_tabs_in_log;
39 int need_8bit_cte;
40 char *notes_message;
41 struct reflog_walk_info *reflog_info;
42 struct rev_info *rev;
43 const char *output_encoding;
44 struct string_list *mailmap;
45 int color;
46 struct ident_split *from_ident;
47 unsigned encode_email_headers:1;
50 * Fields below here are manipulated internally by pp_* functions and
51 * should not be counted on by callers.
53 struct string_list in_body_headers;
54 int graph_width;
57 /* Check whether commit format is mail. */
58 static inline int cmit_fmt_is_mail(enum cmit_fmt fmt)
60 return (fmt == CMIT_FMT_EMAIL || fmt == CMIT_FMT_MBOXRD);
63 struct userformat_want {
64 unsigned notes:1;
65 unsigned source:1;
68 /* Set the flag "w->notes" if there is placeholder %N in "fmt". */
69 void userformat_find_requirements(const char *fmt, struct userformat_want *w);
72 * Shortcut for invoking pretty_print_commit if we do not have any context.
73 * Context would be set empty except "fmt".
75 void pp_commit_easy(enum cmit_fmt fmt, const struct commit *commit,
76 struct strbuf *sb);
79 * Get information about user and date from "line", format it and
80 * put it into "sb".
81 * Format of "line" must be readable for split_ident_line function.
82 * The resulting format is "what: name <email> date".
84 void pp_user_info(struct pretty_print_context *pp, const char *what,
85 struct strbuf *sb, const char *line,
86 const char *encoding);
89 * Format title line of commit message taken from "msg_p" and
90 * put it into "sb".
91 * First line of "msg_p" is also affected.
93 void pp_title_line(struct pretty_print_context *pp, const char **msg_p,
94 struct strbuf *sb, const char *encoding,
95 int need_8bit_cte);
98 * Get current state of commit message from "msg_p" and continue formatting
99 * by adding indentation and '>' signs. Put result into "sb".
101 void pp_remainder(struct pretty_print_context *pp, const char **msg_p,
102 struct strbuf *sb, int indent);
105 * Create a text message about commit using given "format" and "context".
106 * Put the result to "sb".
107 * Please use this function for custom formats.
109 void repo_format_commit_message(struct repository *r,
110 const struct commit *commit,
111 const char *format, struct strbuf *sb,
112 const struct pretty_print_context *context);
113 #ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
114 #define format_commit_message(c, f, s, con) \
115 repo_format_commit_message(the_repository, c, f, s, con)
116 #endif
119 * Parse given arguments from "arg", check it for correctness and
120 * fill struct rev_info.
122 void get_commit_format(const char *arg, struct rev_info *);
125 * Make a commit message with all rules from given "pp"
126 * and put it into "sb".
127 * Please use this function if you have a context (candidate for "pp").
129 void pretty_print_commit(struct pretty_print_context *pp,
130 const struct commit *commit,
131 struct strbuf *sb);
134 * Change line breaks in "msg" to "line_separator" and put it into "sb".
135 * Return "msg" itself.
137 const char *format_subject(struct strbuf *sb, const char *msg,
138 const char *line_separator);
140 /* Check if "cmit_fmt" will produce an empty output. */
141 int commit_format_is_empty(enum cmit_fmt);
143 /* Make subject of commit message suitable for filename */
144 void format_sanitized_subject(struct strbuf *sb, const char *msg, size_t len);
147 * Set values of fields in "struct process_trailer_options"
148 * according to trailers arguments.
150 int format_set_trailers_options(struct process_trailer_options *opts,
151 struct string_list *filter_list,
152 struct strbuf *sepbuf,
153 struct strbuf *kvsepbuf,
154 const char **arg,
155 char **invalid_arg);
157 #endif /* PRETTY_H */