sha1_name: unroll len loop in find_unique_abbrev_r()
[gitweb.git] / trailer.h
index b83b249b6618f0f25f873599bd546da862f17e92..6d7f8c2a52305d3d937b69a877f1ae0b7af94363 100644 (file)
--- a/trailer.h
+++ b/trailer.h
@@ -4,12 +4,14 @@
 #include "list.h"
 
 enum trailer_where {
+       WHERE_DEFAULT,
        WHERE_END,
        WHERE_AFTER,
        WHERE_BEFORE,
        WHERE_START
 };
 enum trailer_if_exists {
+       EXISTS_DEFAULT,
        EXISTS_ADD_IF_DIFFERENT_NEIGHBOR,
        EXISTS_ADD_IF_DIFFERENT,
        EXISTS_ADD,
@@ -17,6 +19,7 @@ enum trailer_if_exists {
        EXISTS_DO_NOTHING
 };
 enum trailer_if_missing {
+       MISSING_DEFAULT,
        MISSING_ADD,
        MISSING_DO_NOTHING
 };
@@ -54,13 +57,42 @@ struct new_trailer_item {
        struct list_head list;
 
        const char *text;
+
+       enum trailer_where where;
+       enum trailer_if_exists if_exists;
+       enum trailer_if_missing if_missing;
+};
+
+struct process_trailer_options {
+       int in_place;
+       int trim_empty;
+       int only_trailers;
+       int only_input;
+       int unfold;
 };
 
-void process_trailers(const char *file, int in_place, int trim_empty,
+#define PROCESS_TRAILER_OPTIONS_INIT {0}
+
+void process_trailers(const char *file,
+                     const struct process_trailer_options *opts,
                      struct list_head *new_trailer_head);
 
 void trailer_info_get(struct trailer_info *info, const char *str);
 
 void trailer_info_release(struct trailer_info *info);
 
+/*
+ * Format the trailers from the commit msg "msg" into the strbuf "out".
+ * Note two caveats about "opts":
+ *
+ *   - this is primarily a helper for pretty.c, and not
+ *     all of the flags are supported.
+ *
+ *   - this differs from process_trailers slightly in that we always format
+ *     only the trailer block itself, even if the "only_trailers" option is not
+ *     set.
+ */
+void format_trailers_from_commit(struct strbuf *out, const char *msg,
+                                const struct process_trailer_options *opts);
+
 #endif /* TRAILER_H */