Line | Count | Source |
1 | | #ifndef PRETTY_H |
2 | | #define PRETTY_H |
3 | | |
4 | | #include "date.h" |
5 | | #include "string-list.h" |
6 | | |
7 | | struct commit; |
8 | | struct repository; |
9 | | struct strbuf; |
10 | | struct process_trailer_options; |
11 | | |
12 | | /* Commit formats */ |
13 | | enum cmit_fmt { |
14 | | CMIT_FMT_RAW, |
15 | | CMIT_FMT_MEDIUM, |
16 | | CMIT_FMT_DEFAULT = CMIT_FMT_MEDIUM, |
17 | | CMIT_FMT_SHORT, |
18 | | CMIT_FMT_FULL, |
19 | | CMIT_FMT_FULLER, |
20 | | CMIT_FMT_ONELINE, |
21 | | CMIT_FMT_EMAIL, |
22 | | CMIT_FMT_MBOXRD, |
23 | | CMIT_FMT_USERFORMAT, |
24 | | |
25 | | CMIT_FMT_UNSPECIFIED |
26 | | }; |
27 | | |
28 | | struct pretty_print_describe_status { |
29 | | unsigned int max_invocations; |
30 | | }; |
31 | | |
32 | | struct pretty_print_context { |
33 | | /* |
34 | | * Callers should tweak these to change the behavior of pp_* functions. |
35 | | */ |
36 | | enum cmit_fmt fmt; |
37 | | int abbrev; |
38 | | char *after_subject; |
39 | | int preserve_subject; |
40 | | struct date_mode date_mode; |
41 | | unsigned date_mode_explicit:1; |
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; |
51 | | unsigned encode_email_headers:1; |
52 | | struct pretty_print_describe_status *describe_status; |
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 | | |
62 | | /* Check whether commit format is mail. */ |
63 | | static inline int cmit_fmt_is_mail(enum cmit_fmt fmt) |
64 | 19.5k | { |
65 | 19.5k | return (fmt == CMIT_FMT_EMAIL || fmt == CMIT_FMT_MBOXRD); |
66 | 19.5k | } Unexecuted instantiation: add.c:cmit_fmt_is_mail Unexecuted instantiation: am.c:cmit_fmt_is_mail Unexecuted instantiation: bisect.c:cmit_fmt_is_mail Unexecuted instantiation: blame.c:cmit_fmt_is_mail Unexecuted instantiation: checkout.c:cmit_fmt_is_mail Unexecuted instantiation: commit.c:cmit_fmt_is_mail Unexecuted instantiation: describe.c:cmit_fmt_is_mail Unexecuted instantiation: diff-files.c:cmit_fmt_is_mail Unexecuted instantiation: diff-index.c:cmit_fmt_is_mail Unexecuted instantiation: diff-tree.c:cmit_fmt_is_mail Unexecuted instantiation: diff.c:cmit_fmt_is_mail Unexecuted instantiation: fast-export.c:cmit_fmt_is_mail Unexecuted instantiation: log.c:cmit_fmt_is_mail Unexecuted instantiation: merge.c:cmit_fmt_is_mail Unexecuted instantiation: notes.c:cmit_fmt_is_mail Unexecuted instantiation: pack-objects.c:cmit_fmt_is_mail Unexecuted instantiation: pack-refs.c:cmit_fmt_is_mail Unexecuted instantiation: prune.c:cmit_fmt_is_mail Unexecuted instantiation: rebase.c:cmit_fmt_is_mail Unexecuted instantiation: reflog.c:cmit_fmt_is_mail Unexecuted instantiation: replay.c:cmit_fmt_is_mail Unexecuted instantiation: reset.c:cmit_fmt_is_mail Unexecuted instantiation: rev-list.c:cmit_fmt_is_mail Unexecuted instantiation: rev-parse.c:cmit_fmt_is_mail Unexecuted instantiation: revert.c:cmit_fmt_is_mail Unexecuted instantiation: shortlog.c:cmit_fmt_is_mail Unexecuted instantiation: show-branch.c:cmit_fmt_is_mail Unexecuted instantiation: stash.c:cmit_fmt_is_mail Unexecuted instantiation: submodule--helper.c:cmit_fmt_is_mail Unexecuted instantiation: tag.c:cmit_fmt_is_mail Unexecuted instantiation: add-interactive.c:cmit_fmt_is_mail Unexecuted instantiation: archive.c:cmit_fmt_is_mail Unexecuted instantiation: attr.c:cmit_fmt_is_mail Unexecuted instantiation: bundle.c:cmit_fmt_is_mail Unexecuted instantiation: combine-diff.c:cmit_fmt_is_mail Unexecuted instantiation: commit-reach.c:cmit_fmt_is_mail Unexecuted instantiation: diff-merges.c:cmit_fmt_is_mail Unexecuted instantiation: diff-lib.c:cmit_fmt_is_mail Unexecuted instantiation: diff-no-index.c:cmit_fmt_is_mail Unexecuted instantiation: diffcore-pickaxe.c:cmit_fmt_is_mail Unexecuted instantiation: fmt-merge-msg.c:cmit_fmt_is_mail Unexecuted instantiation: graph.c:cmit_fmt_is_mail Unexecuted instantiation: grep.c:cmit_fmt_is_mail Unexecuted instantiation: line-log.c:cmit_fmt_is_mail Unexecuted instantiation: list-objects.c:cmit_fmt_is_mail log-tree.c:cmit_fmt_is_mail Line | Count | Source | 64 | 19.5k | { | 65 | 19.5k | return (fmt == CMIT_FMT_EMAIL || fmt == CMIT_FMT_MBOXRD); | 66 | 19.5k | } |
Unexecuted instantiation: merge-ort.c:cmit_fmt_is_mail Unexecuted instantiation: merge-recursive.c:cmit_fmt_is_mail Unexecuted instantiation: midx-write.c:cmit_fmt_is_mail Unexecuted instantiation: notes-cache.c:cmit_fmt_is_mail Unexecuted instantiation: object-name.c:cmit_fmt_is_mail Unexecuted instantiation: pack-bitmap-write.c:cmit_fmt_is_mail Unexecuted instantiation: pack-bitmap.c:cmit_fmt_is_mail Unexecuted instantiation: pretty.c:cmit_fmt_is_mail Unexecuted instantiation: range-diff.c:cmit_fmt_is_mail Unexecuted instantiation: reachable.c:cmit_fmt_is_mail Unexecuted instantiation: read-cache.c:cmit_fmt_is_mail Unexecuted instantiation: ref-filter.c:cmit_fmt_is_mail Unexecuted instantiation: reflog-walk.c:cmit_fmt_is_mail Unexecuted instantiation: files-backend.c:cmit_fmt_is_mail Unexecuted instantiation: remote.c:cmit_fmt_is_mail Unexecuted instantiation: revision.c:cmit_fmt_is_mail Unexecuted instantiation: sequencer.c:cmit_fmt_is_mail Unexecuted instantiation: shallow.c:cmit_fmt_is_mail Unexecuted instantiation: submodule.c:cmit_fmt_is_mail Unexecuted instantiation: upload-pack.c:cmit_fmt_is_mail Unexecuted instantiation: wt-status.c:cmit_fmt_is_mail Unexecuted instantiation: list-objects-filter.c:cmit_fmt_is_mail |
67 | | |
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 | | */ |
73 | | struct userformat_want { |
74 | | unsigned notes:1; |
75 | | unsigned source:1; |
76 | | unsigned decorate:1; |
77 | | }; |
78 | | void userformat_find_requirements(const char *fmt, struct userformat_want *w); |
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 | | */ |
84 | | void pp_commit_easy(enum cmit_fmt fmt, const struct commit *commit, |
85 | | struct strbuf *sb); |
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 | | */ |
93 | | void pp_user_info(struct pretty_print_context *pp, const char *what, |
94 | | struct strbuf *sb, const char *line, |
95 | | const char *encoding); |
96 | | |
97 | | /* |
98 | | * Format subject line of commit message taken from "msg_p" and |
99 | | * put it into "sb". |
100 | | * First line of "msg_p" is also affected. |
101 | | */ |
102 | | void pp_email_subject(struct pretty_print_context *pp, const char **msg_p, |
103 | | struct strbuf *sb, const char *encoding, |
104 | | int need_8bit_cte); |
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 | | */ |
110 | | void pp_remainder(struct pretty_print_context *pp, const char **msg_p, |
111 | | struct strbuf *sb, int indent); |
112 | | |
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 | | */ |
118 | | void repo_format_commit_message(struct repository *r, |
119 | | const struct commit *commit, |
120 | | const char *format, struct strbuf *sb, |
121 | | const struct pretty_print_context *context); |
122 | | |
123 | | /* |
124 | | * Parse given arguments from "arg", check it for correctness and |
125 | | * fill struct rev_info. |
126 | | */ |
127 | | void get_commit_format(const char *arg, struct rev_info *); |
128 | | |
129 | | /* |
130 | | * Make a commit message with all rules from given "pp" |
131 | | * and put it into "sb". |
132 | | * Please use this function if you have a context (candidate for "pp"). |
133 | | */ |
134 | | void pretty_print_commit(struct pretty_print_context *pp, |
135 | | const struct commit *commit, |
136 | | struct strbuf *sb); |
137 | | |
138 | | /* |
139 | | * Change line breaks in "msg" to "line_separator" and put it into "sb". |
140 | | * Return "msg" itself. |
141 | | */ |
142 | | const char *format_subject(struct strbuf *sb, const char *msg, |
143 | | const char *line_separator); |
144 | | |
145 | | /* Check if "cmit_fmt" will produce an empty output. */ |
146 | | int commit_format_is_empty(enum cmit_fmt); |
147 | | |
148 | | /* Make subject of commit message suitable for filename */ |
149 | | void format_sanitized_subject(struct strbuf *sb, const char *msg, size_t len); |
150 | | |
151 | | int has_non_ascii(const char *text); |
152 | | |
153 | | /* |
154 | | * Set values of fields in "struct process_trailer_options" |
155 | | * according to trailers arguments. |
156 | | */ |
157 | | int format_set_trailers_options(struct process_trailer_options *opts, |
158 | | struct string_list *filter_list, |
159 | | struct strbuf *sepbuf, |
160 | | struct strbuf *kvsepbuf, |
161 | | const char **arg, |
162 | | char **invalid_arg); |
163 | | |
164 | | /* |
165 | | * Like show_date, but pull the timestamp and tz parameters from |
166 | | * the ident_split. It will also sanity-check the values and produce |
167 | | * a well-known sentinel date if they appear bogus. |
168 | | */ |
169 | | const char *show_ident_date(const struct ident_split *id, |
170 | | struct date_mode mode); |
171 | | |
172 | | |
173 | | #endif /* PRETTY_H */ |