1#ifndef PRETTY_H 2#define PRETTY_H 3 4#include"cache.h" 5#include"string-list.h" 6 7struct commit; 8struct strbuf; 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 */ 30enum cmit_fmt fmt; 31int abbrev; 32const char*after_subject; 33int preserve_subject; 34struct date_mode date_mode; 35unsigned date_mode_explicit:1; 36int print_email_subject; 37int expand_tabs_in_log; 38int need_8bit_cte; 39char*notes_message; 40struct reflog_walk_info *reflog_info; 41struct rev_info *rev; 42const char*output_encoding; 43struct string_list *mailmap; 44int color; 45struct ident_split *from_ident; 46 47/* 48 * Fields below here are manipulated internally by pp_* functions and 49 * should not be counted on by callers. 50 */ 51struct string_list in_body_headers; 52int graph_width; 53}; 54 55/* Check whether commit format is mail. */ 56staticinlineintcmit_fmt_is_mail(enum cmit_fmt fmt) 57{ 58return(fmt == CMIT_FMT_EMAIL || fmt == CMIT_FMT_MBOXRD); 59} 60 61struct userformat_want { 62unsigned notes:1; 63}; 64 65/* Set the flag "w->notes" if there is placeholder %N in "fmt". */ 66voiduserformat_find_requirements(const char*fmt,struct userformat_want *w); 67 68/* 69 * Shortcut for invoking pretty_print_commit if we do not have any context. 70 * Context would be set empty except "fmt". 71 */ 72voidpp_commit_easy(enum cmit_fmt fmt,const struct commit *commit, 73struct strbuf *sb); 74 75/* 76 * Get information about user and date from "line", format it and 77 * put it into "sb". 78 * Format of "line" must be readable for split_ident_line function. 79 * The resulting format is "what: name <email> date". 80 */ 81voidpp_user_info(struct pretty_print_context *pp,const char*what, 82struct strbuf *sb,const char*line, 83const char*encoding); 84 85/* 86 * Format title line of commit message taken from "msg_p" and 87 * put it into "sb". 88 * First line of "msg_p" is also affected. 89 */ 90voidpp_title_line(struct pretty_print_context *pp,const char**msg_p, 91struct strbuf *sb,const char*encoding, 92int need_8bit_cte); 93 94/* 95 * Get current state of commit message from "msg_p" and continue formatting 96 * by adding indentation and '>' signs. Put result into "sb". 97 */ 98voidpp_remainder(struct pretty_print_context *pp,const char**msg_p, 99struct strbuf *sb,int indent); 100 101/* 102 * Create a text message about commit using given "format" and "context". 103 * Put the result to "sb". 104 * Please use this function for custom formats. 105 */ 106voidrepo_format_commit_message(struct repository *r, 107const struct commit *commit, 108const char*format,struct strbuf *sb, 109const struct pretty_print_context *context); 110#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS 111#define format_commit_message(c, f, s, con) \ 112 repo_format_commit_message(the_repository, c, f, s, con) 113#endif 114 115/* 116 * Parse given arguments from "arg", check it for correctness and 117 * fill struct rev_info. 118 */ 119voidget_commit_format(const char*arg,struct rev_info *); 120 121/* 122 * Make a commit message with all rules from given "pp" 123 * and put it into "sb". 124 * Please use this function if you have a context (candidate for "pp"). 125 */ 126voidpretty_print_commit(struct pretty_print_context *pp, 127const struct commit *commit, 128struct strbuf *sb); 129 130/* 131 * Change line breaks in "msg" to "line_separator" and put it into "sb". 132 * Return "msg" itself. 133 */ 134const char*format_subject(struct strbuf *sb,const char*msg, 135const char*line_separator); 136 137/* Check if "cmit_fmt" will produce an empty output. */ 138intcommit_format_is_empty(enum cmit_fmt); 139 140#endif/* PRETTY_H */