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