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.

107 lines
2.5KB

  1. #ifndef TRAILER_H
  2. #define TRAILER_H
  3. #include "list.h"
  4. struct strbuf;
  5. enum trailer_where {
  6. WHERE_DEFAULT,
  7. WHERE_END,
  8. WHERE_AFTER,
  9. WHERE_BEFORE,
  10. WHERE_START
  11. };
  12. enum trailer_if_exists {
  13. EXISTS_DEFAULT,
  14. EXISTS_ADD_IF_DIFFERENT_NEIGHBOR,
  15. EXISTS_ADD_IF_DIFFERENT,
  16. EXISTS_ADD,
  17. EXISTS_REPLACE,
  18. EXISTS_DO_NOTHING
  19. };
  20. enum trailer_if_missing {
  21. MISSING_DEFAULT,
  22. MISSING_ADD,
  23. MISSING_DO_NOTHING
  24. };
  25. int trailer_set_where(enum trailer_where *item, const char *value);
  26. int trailer_set_if_exists(enum trailer_if_exists *item, const char *value);
  27. int trailer_set_if_missing(enum trailer_if_missing *item, const char *value);
  28. struct trailer_info {
  29. /*
  30. * True if there is a blank line before the location pointed to by
  31. * trailer_start.
  32. */
  33. int blank_line_before_trailer;
  34. /*
  35. * Pointers to the start and end of the trailer block found. If there
  36. * is no trailer block found, these 2 pointers point to the end of the
  37. * input string.
  38. */
  39. const char *trailer_start, *trailer_end;
  40. /*
  41. * Array of trailers found.
  42. */
  43. char **trailers;
  44. size_t trailer_nr;
  45. };
  46. /*
  47. * A list that represents newly-added trailers, such as those provided
  48. * with the --trailer command line option of git-interpret-trailers.
  49. */
  50. struct new_trailer_item {
  51. struct list_head list;
  52. const char *text;
  53. enum trailer_where where;
  54. enum trailer_if_exists if_exists;
  55. enum trailer_if_missing if_missing;
  56. };
  57. struct process_trailer_options {
  58. int in_place;
  59. int trim_empty;
  60. int only_trailers;
  61. int only_input;
  62. int unfold;
  63. int no_divider;
  64. int value_only;
  65. const struct strbuf *separator;
  66. int (*filter)(const struct strbuf *, void *);
  67. void *filter_data;
  68. };
  69. #define PROCESS_TRAILER_OPTIONS_INIT {0}
  70. void process_trailers(const char *file,
  71. const struct process_trailer_options *opts,
  72. struct list_head *new_trailer_head);
  73. void trailer_info_get(struct trailer_info *info, const char *str,
  74. const struct process_trailer_options *opts);
  75. void trailer_info_release(struct trailer_info *info);
  76. /*
  77. * Format the trailers from the commit msg "msg" into the strbuf "out".
  78. * Note two caveats about "opts":
  79. *
  80. * - this is primarily a helper for pretty.c, and not
  81. * all of the flags are supported.
  82. *
  83. * - this differs from process_trailers slightly in that we always format
  84. * only the trailer block itself, even if the "only_trailers" option is not
  85. * set.
  86. */
  87. void format_trailers_from_commit(struct strbuf *out, const char *msg,
  88. const struct process_trailer_options *opts);
  89. #endif /* TRAILER_H */