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