THIS IS A TEST INSTANCE ONLY! REPOSITORIES CAN BE DELETED AT ANY TIME!

Git Source Code Mirror - This is a publish-only repository and all pull requests are ignored. Please follow Documentation/SubmittingPatches procedure for any of your improvements.
git
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

142 lines
3.7KB

  1. #ifndef PRETTY_H
  2. #define PRETTY_H
  3. #include "cache.h"
  4. #include "string-list.h"
  5. struct commit;
  6. struct strbuf;
  7. /* Commit formats */
  8. enum cmit_fmt {
  9. CMIT_FMT_RAW,
  10. CMIT_FMT_MEDIUM,
  11. CMIT_FMT_DEFAULT = CMIT_FMT_MEDIUM,
  12. CMIT_FMT_SHORT,
  13. CMIT_FMT_FULL,
  14. CMIT_FMT_FULLER,
  15. CMIT_FMT_ONELINE,
  16. CMIT_FMT_EMAIL,
  17. CMIT_FMT_MBOXRD,
  18. CMIT_FMT_USERFORMAT,
  19. CMIT_FMT_UNSPECIFIED
  20. };
  21. struct pretty_print_context {
  22. /*
  23. * Callers should tweak these to change the behavior of pp_* functions.
  24. */
  25. enum cmit_fmt fmt;
  26. int abbrev;
  27. const char *after_subject;
  28. int preserve_subject;
  29. struct date_mode date_mode;
  30. unsigned date_mode_explicit:1;
  31. int print_email_subject;
  32. int expand_tabs_in_log;
  33. int need_8bit_cte;
  34. char *notes_message;
  35. struct reflog_walk_info *reflog_info;
  36. struct rev_info *rev;
  37. const char *output_encoding;
  38. struct string_list *mailmap;
  39. int color;
  40. struct ident_split *from_ident;
  41. /*
  42. * Fields below here are manipulated internally by pp_* functions and
  43. * should not be counted on by callers.
  44. */
  45. struct string_list in_body_headers;
  46. int graph_width;
  47. };
  48. /* Check whether commit format is mail. */
  49. static inline int cmit_fmt_is_mail(enum cmit_fmt fmt)
  50. {
  51. return (fmt == CMIT_FMT_EMAIL || fmt == CMIT_FMT_MBOXRD);
  52. }
  53. struct userformat_want {
  54. unsigned notes:1;
  55. unsigned source:1;
  56. };
  57. /* Set the flag "w->notes" if there is placeholder %N in "fmt". */
  58. void userformat_find_requirements(const char *fmt, struct userformat_want *w);
  59. /*
  60. * Shortcut for invoking pretty_print_commit if we do not have any context.
  61. * Context would be set empty except "fmt".
  62. */
  63. void pp_commit_easy(enum cmit_fmt fmt, const struct commit *commit,
  64. struct strbuf *sb);
  65. /*
  66. * Get information about user and date from "line", format it and
  67. * put it into "sb".
  68. * Format of "line" must be readable for split_ident_line function.
  69. * The resulting format is "what: name <email> date".
  70. */
  71. void pp_user_info(struct pretty_print_context *pp, const char *what,
  72. struct strbuf *sb, const char *line,
  73. const char *encoding);
  74. /*
  75. * Format title line of commit message taken from "msg_p" and
  76. * put it into "sb".
  77. * First line of "msg_p" is also affected.
  78. */
  79. void pp_title_line(struct pretty_print_context *pp, const char **msg_p,
  80. struct strbuf *sb, const char *encoding,
  81. int need_8bit_cte);
  82. /*
  83. * Get current state of commit message from "msg_p" and continue formatting
  84. * by adding indentation and '>' signs. Put result into "sb".
  85. */
  86. void pp_remainder(struct pretty_print_context *pp, const char **msg_p,
  87. struct strbuf *sb, int indent);
  88. /*
  89. * Create a text message about commit using given "format" and "context".
  90. * Put the result to "sb".
  91. * Please use this function for custom formats.
  92. */
  93. void repo_format_commit_message(struct repository *r,
  94. const struct commit *commit,
  95. const char *format, struct strbuf *sb,
  96. const struct pretty_print_context *context);
  97. #ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
  98. #define format_commit_message(c, f, s, con) \
  99. repo_format_commit_message(the_repository, c, f, s, con)
  100. #endif
  101. /*
  102. * Parse given arguments from "arg", check it for correctness and
  103. * fill struct rev_info.
  104. */
  105. void get_commit_format(const char *arg, struct rev_info *);
  106. /*
  107. * Make a commit message with all rules from given "pp"
  108. * and put it into "sb".
  109. * Please use this function if you have a context (candidate for "pp").
  110. */
  111. void pretty_print_commit(struct pretty_print_context *pp,
  112. const struct commit *commit,
  113. struct strbuf *sb);
  114. /*
  115. * Change line breaks in "msg" to "line_separator" and put it into "sb".
  116. * Return "msg" itself.
  117. */
  118. const char *format_subject(struct strbuf *sb, const char *msg,
  119. const char *line_separator);
  120. /* Check if "cmit_fmt" will produce an empty output. */
  121. int commit_format_is_empty(enum cmit_fmt);
  122. #endif /* PRETTY_H */