{"thread":{"id":"47408","subject":"[PATCH Outreachy 2/2] format: create docs for pretty.h","startedAt":"2017-12-08T13:22:04Z","lastAt":"2017-12-12T22:12:58Z","messageCount":14,"participants":["Olga Telezhnaya","Junio C Hamano","Eric Sunshine","Оля Тележная","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"334415","messageId":"01020160364a2471-0e40e237-80b4-485c-a987-9c83206a2ee5-000000@eu-west-1.amazonses.com","threadId":"47408","inReplyTo":"01020160364a23d5-471a2fd0-9fff-4599-86f8-b2f37a4a0a84-000000@eu-west-1.amazonses.com","subject":"[PATCH Outreachy 2/2] format: create docs for pretty.h","fromName":"Olga Telezhnaya","fromEmail":"olyatelezhnaya@gmail.com","sentAt":"2017-12-08T13:21:56Z","receivedAt":"2017-12-08T13:22:04Z","isPatch":true,"sender":{"key":"olyatelezhnaya@gmail.com","avatar":"https://avatars.githubusercontent.com/u/11246099?v=4"},"body":"Write some docs for functions in pretty.h.\nTake it as a first draft, they would be changed later.\n\nSigned-off-by: Olga Telezhnaia <olyatelezhnaya@gmail.com>\nMentored-by: Christian Couder <christian.couder@gmail.com>\nMentored by: Jeff King <peff@peff.net>\n---\n pretty.h | 44 ++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 44 insertions(+)\n\ndiff --git a/pretty.h b/pretty.h\nindex ef5167484fb64..5c85d94e332d7 100644\n--- a/pretty.h\n+++ b/pretty.h\n@@ -48,6 +48,7 @@ struct pretty_print_context {\n \tint graph_width;\n };\n \n+/* Check whether commit format is mail. */\n static inline int cmit_fmt_is_mail(enum cmit_fmt fmt)\n {\n \treturn (fmt == CMIT_FMT_EMAIL || fmt == CMIT_FMT_MBOXRD);\n@@ -57,31 +58,74 @@ struct userformat_want {\n \tunsigned notes:1;\n };\n \n+/* Set the flag \"w->notes\" if there is placeholder %N in \"fmt\". */\n void userformat_find_requirements(const char *fmt, struct userformat_want *w);\n+\n+/*\n+ * Shortcut for invoking pretty_print_commit if we do not have any context.\n+ * Context would be set empty except \"fmt\".\n+ */\n void pp_commit_easy(enum cmit_fmt fmt, const struct commit *commit,\n \t\t\tstruct strbuf *sb);\n+\n+/*\n+ * Get information about user and date from \"line\", format it and\n+ * put it into \"sb\".\n+ * Format of \"line\" must be readable for split_ident_line function.\n+ * The resulting format is \"what: name <email> date\".\n+ */\n void pp_user_info(struct pretty_print_context *pp, const char *what,\n \t\t\tstruct strbuf *sb, const char *line,\n \t\t\tconst char *encoding);\n+\n+/*\n+ * Format title line of commit message taken from \"msg_p\" and\n+ * put it into \"sb\".\n+ * First line of \"msg_p\" is also affected.\n+ */\n void pp_title_line(struct pretty_print_context *pp, const char **msg_p,\n \t\t\tstruct strbuf *sb, const char *encoding,\n \t\t\tint need_8bit_cte);\n+\n+/*\n+ * Get current state of commit message from \"msg_p\" and continue formatting\n+ * by adding indentation and '>' signs. Put result into \"sb\".\n+ */\n void pp_remainder(struct pretty_print_context *pp, const char **msg_p,\n \t\t\tstruct strbuf *sb, int indent);\n \n+/*\n+ * Create a text message about commit using given \"format\" and \"context\".\n+ * Put the result to \"sb\".\n+ * Please use this function for custom formats.\n+ */\n void format_commit_message(const struct commit *commit,\n \t\t\tconst char *format, struct strbuf *sb,\n \t\t\tconst struct pretty_print_context *context);\n \n+/*\n+ * Parse given arguments from \"arg\", check it for correctness and\n+ * fill struct rev_info.\n+ */\n void get_commit_format(const char *arg, struct rev_info *);\n \n+/*\n+ * Make a commit message with all rules from given \"pp\"\n+ * and put it into \"sb\".\n+ * Please use this function if you have a context (candidate for \"pp\").\n+ */\n void pretty_print_commit(struct pretty_print_context *pp,\n \t\t\tconst struct commit *commit,\n \t\t\tstruct strbuf *sb);\n \n+/*\n+ * Change line breaks in \"msg\" to \"line_separator\" and put it into \"sb\".\n+ * Return \"msg\" itself.\n+ */\n const char *format_subject(struct strbuf *sb, const char *msg,\n \t\t\tconst char *line_separator);\n \n+/* Check if \"cmit_fmt\" will produce an empty output. */\n int commit_format_is_empty(enum cmit_fmt);\n \n #endif /* PRETTY_H */\n\n--\nhttps://github.com/git/git/pull/439\n"},{"id":"334416","messageId":"01020160364a23d5-471a2fd0-9fff-4599-86f8-b2f37a4a0a84-000000@eu-west-1.amazonses.com","threadId":"47408","inReplyTo":null,"subject":"[PATCH Outreachy 1/2] format: create pretty.h file","fromName":"Olga Telezhnaya","fromEmail":"olyatelezhnaya@gmail.com","sentAt":"2017-12-08T13:21:56Z","receivedAt":"2017-12-08T13:22:06Z","isPatch":true,"sender":{"key":"olyatelezhnaya@gmail.com","avatar":"https://avatars.githubusercontent.com/u/11246099?v=4"},"body":"Create header for pretty.c to make formatting interface more structured.\nThis is a middle point, this file would be merged futher with other\nfiles which contain formatting stuff.\n\nSigned-off-by: Olga Telezhnaia <olyatelezhnaya@gmail.com>\nMentored-by: Christian Couder <christian.couder@gmail.com>\nMentored by: Jeff King <peff@peff.net>\n---\n archive.c             |  1 +\n builtin/notes.c       |  2 +-\n builtin/reset.c       |  2 +-\n builtin/show-branch.c |  2 +-\n combine-diff.c        |  1 +\n commit.c              |  1 +\n commit.h              | 80 ----------------------------------------------\n diffcore-pickaxe.c    |  1 +\n grep.c                |  1 +\n log-tree.c            |  1 +\n notes-cache.c         |  1 +\n pretty.h              | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++\n revision.h            |  2 +-\n sequencer.c           |  1 +\n sha1_name.c           |  1 +\n submodule.c           |  1 +\n 16 files changed, 101 insertions(+), 84 deletions(-)\n create mode 100644 pretty.h\n\ndiff --git a/archive.c b/archive.c\nindex 0b7b62af0c3ec..60607e8c00857 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -2,6 +2,7 @@\n #include \"config.h\"\n #include \"refs.h\"\n #include \"commit.h\"\n+#include \"pretty.h\"\n #include \"tree-walk.h\"\n #include \"attr.h\"\n #include \"archive.h\"\ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex 1a2c7d92ad7e7..7c8176164561b 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -12,7 +12,7 @@\n #include \"builtin.h\"\n #include \"notes.h\"\n #include \"blob.h\"\n-#include \"commit.h\"\n+#include \"pretty.h\"\n #include \"refs.h\"\n #include \"exec_cmd.h\"\n #include \"run-command.h\"\ndiff --git a/builtin/reset.c b/builtin/reset.c\nindex 906e541658230..e15f595799c40 100644\n--- a/builtin/reset.c\n+++ b/builtin/reset.c\n@@ -12,7 +12,7 @@\n #include \"lockfile.h\"\n #include \"tag.h\"\n #include \"object.h\"\n-#include \"commit.h\"\n+#include \"pretty.h\"\n #include \"run-command.h\"\n #include \"refs.h\"\n #include \"diff.h\"\ndiff --git a/builtin/show-branch.c b/builtin/show-branch.c\nindex 2e24b5c330e8e..e8a4aa40cb4b6 100644\n--- a/builtin/show-branch.c\n+++ b/builtin/show-branch.c\n@@ -1,6 +1,6 @@\n #include \"cache.h\"\n #include \"config.h\"\n-#include \"commit.h\"\n+#include \"pretty.h\"\n #include \"refs.h\"\n #include \"builtin.h\"\n #include \"color.h\"\ndiff --git a/combine-diff.c b/combine-diff.c\nindex 2505de119a2be..01ba1b03a06d2 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -1,5 +1,6 @@\n #include \"cache.h\"\n #include \"commit.h\"\n+#include \"pretty.h\"\n #include \"blob.h\"\n #include \"diff.h\"\n #include \"diffcore.h\"\ndiff --git a/commit.c b/commit.c\nindex cab8d4455bdbd..ac17a27a4ab0a 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -1,6 +1,7 @@\n #include \"cache.h\"\n #include \"tag.h\"\n #include \"commit.h\"\n+#include \"pretty.h\"\n #include \"pkt-line.h\"\n #include \"utf8.h\"\n #include \"diff.h\"\ndiff --git a/commit.h b/commit.h\nindex 99a3fea68d3f6..41a2067809444 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -121,93 +121,13 @@ struct commit_list *copy_commit_list(struct commit_list *list);\n \n void free_commit_list(struct commit_list *list);\n \n-/* Commit formats */\n-enum cmit_fmt {\n-\tCMIT_FMT_RAW,\n-\tCMIT_FMT_MEDIUM,\n-\tCMIT_FMT_DEFAULT = CMIT_FMT_MEDIUM,\n-\tCMIT_FMT_SHORT,\n-\tCMIT_FMT_FULL,\n-\tCMIT_FMT_FULLER,\n-\tCMIT_FMT_ONELINE,\n-\tCMIT_FMT_EMAIL,\n-\tCMIT_FMT_MBOXRD,\n-\tCMIT_FMT_USERFORMAT,\n-\n-\tCMIT_FMT_UNSPECIFIED\n-};\n-\n-static inline int cmit_fmt_is_mail(enum cmit_fmt fmt)\n-{\n-\treturn (fmt == CMIT_FMT_EMAIL || fmt == CMIT_FMT_MBOXRD);\n-}\n-\n struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */\n \n-struct pretty_print_context {\n-\t/*\n-\t * Callers should tweak these to change the behavior of pp_* functions.\n-\t */\n-\tenum cmit_fmt fmt;\n-\tint abbrev;\n-\tconst char *after_subject;\n-\tint preserve_subject;\n-\tstruct date_mode date_mode;\n-\tunsigned date_mode_explicit:1;\n-\tint print_email_subject;\n-\tint expand_tabs_in_log;\n-\tint need_8bit_cte;\n-\tchar *notes_message;\n-\tstruct reflog_walk_info *reflog_info;\n-\tstruct rev_info *rev;\n-\tconst char *output_encoding;\n-\tstruct string_list *mailmap;\n-\tint color;\n-\tstruct ident_split *from_ident;\n-\n-\t/*\n-\t * Fields below here are manipulated internally by pp_* functions and\n-\t * should not be counted on by callers.\n-\t */\n-\tstruct string_list in_body_headers;\n-\tint graph_width;\n-};\n-\n-struct userformat_want {\n-\tunsigned notes:1;\n-};\n-\n extern int has_non_ascii(const char *text);\n extern const char *logmsg_reencode(const struct commit *commit,\n \t\t\t\t   char **commit_encoding,\n \t\t\t\t   const char *output_encoding);\n-extern void get_commit_format(const char *arg, struct rev_info *);\n-extern const char *format_subject(struct strbuf *sb, const char *msg,\n-\t\t\t\t  const char *line_separator);\n-extern void userformat_find_requirements(const char *fmt, struct userformat_want *w);\n-extern int commit_format_is_empty(enum cmit_fmt);\n extern const char *skip_blank_lines(const char *msg);\n-extern void format_commit_message(const struct commit *commit,\n-\t\t\t\t  const char *format, struct strbuf *sb,\n-\t\t\t\t  const struct pretty_print_context *context);\n-extern void pretty_print_commit(struct pretty_print_context *pp,\n-\t\t\t\tconst struct commit *commit,\n-\t\t\t\tstruct strbuf *sb);\n-extern void pp_commit_easy(enum cmit_fmt fmt, const struct commit *commit,\n-\t\t\t   struct strbuf *sb);\n-void pp_user_info(struct pretty_print_context *pp,\n-\t\t  const char *what, struct strbuf *sb,\n-\t\t  const char *line, const char *encoding);\n-void pp_title_line(struct pretty_print_context *pp,\n-\t\t   const char **msg_p,\n-\t\t   struct strbuf *sb,\n-\t\t   const char *encoding,\n-\t\t   int need_8bit_cte);\n-void pp_remainder(struct pretty_print_context *pp,\n-\t\t  const char **msg_p,\n-\t\t  struct strbuf *sb,\n-\t\t  int indent);\n-\n \n /** Removes the first commit from a list sorted by date, and adds all\n  * of its parents.\ndiff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c\nindex 9476bd21081f4..c5e12fc096058 100644\n--- a/diffcore-pickaxe.c\n+++ b/diffcore-pickaxe.c\n@@ -8,6 +8,7 @@\n #include \"xdiff-interface.h\"\n #include \"kwset.h\"\n #include \"commit.h\"\n+#include \"pretty.h\"\n #include \"quote.h\"\n \n typedef int (*pickaxe_fn)(mmfile_t *one, mmfile_t *two,\ndiff --git a/grep.c b/grep.c\nindex a69c05edc2e4f..1b99ed01898b0 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -6,6 +6,7 @@\n #include \"diff.h\"\n #include \"diffcore.h\"\n #include \"commit.h\"\n+#include \"pretty.h\"\n #include \"quote.h\"\n \n static int grep_source_load(struct grep_source *gs);\ndiff --git a/log-tree.c b/log-tree.c\nindex 3b904f0375e23..c305eeff80aa0 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -2,6 +2,7 @@\n #include \"config.h\"\n #include \"diff.h\"\n #include \"commit.h\"\n+#include \"pretty.h\"\n #include \"tag.h\"\n #include \"graph.h\"\n #include \"log-tree.h\"\ndiff --git a/notes-cache.c b/notes-cache.c\nindex 17ee8602b3d2f..d6346a095c18b 100644\n--- a/notes-cache.c\n+++ b/notes-cache.c\n@@ -1,6 +1,7 @@\n #include \"cache.h\"\n #include \"notes-cache.h\"\n #include \"commit.h\"\n+#include \"pretty.h\"\n #include \"refs.h\"\n \n static int notes_cache_match_validity(const char *ref, const char *validity)\ndiff --git a/pretty.h b/pretty.h\nnew file mode 100644\nindex 0000000000000..ef5167484fb64\n--- /dev/null\n+++ b/pretty.h\n@@ -0,0 +1,87 @@\n+#ifndef PRETTY_H\n+#define PRETTY_H\n+\n+struct commit;\n+\n+/* Commit formats */\n+enum cmit_fmt {\n+\tCMIT_FMT_RAW,\n+\tCMIT_FMT_MEDIUM,\n+\tCMIT_FMT_DEFAULT = CMIT_FMT_MEDIUM,\n+\tCMIT_FMT_SHORT,\n+\tCMIT_FMT_FULL,\n+\tCMIT_FMT_FULLER,\n+\tCMIT_FMT_ONELINE,\n+\tCMIT_FMT_EMAIL,\n+\tCMIT_FMT_MBOXRD,\n+\tCMIT_FMT_USERFORMAT,\n+\n+\tCMIT_FMT_UNSPECIFIED\n+};\n+\n+struct pretty_print_context {\n+\t/*\n+\t * Callers should tweak these to change the behavior of pp_* functions.\n+\t */\n+\tenum cmit_fmt fmt;\n+\tint abbrev;\n+\tconst char *after_subject;\n+\tint preserve_subject;\n+\tstruct date_mode date_mode;\n+\tunsigned date_mode_explicit:1;\n+\tint print_email_subject;\n+\tint expand_tabs_in_log;\n+\tint need_8bit_cte;\n+\tchar *notes_message;\n+\tstruct reflog_walk_info *reflog_info;\n+\tstruct rev_info *rev;\n+\tconst char *output_encoding;\n+\tstruct string_list *mailmap;\n+\tint color;\n+\tstruct ident_split *from_ident;\n+\n+\t/*\n+\t * Fields below here are manipulated internally by pp_* functions and\n+\t * should not be counted on by callers.\n+\t */\n+\tstruct string_list in_body_headers;\n+\tint graph_width;\n+};\n+\n+static inline int cmit_fmt_is_mail(enum cmit_fmt fmt)\n+{\n+\treturn (fmt == CMIT_FMT_EMAIL || fmt == CMIT_FMT_MBOXRD);\n+}\n+\n+struct userformat_want {\n+\tunsigned notes:1;\n+};\n+\n+void userformat_find_requirements(const char *fmt, struct userformat_want *w);\n+void pp_commit_easy(enum cmit_fmt fmt, const struct commit *commit,\n+\t\t\tstruct strbuf *sb);\n+void pp_user_info(struct pretty_print_context *pp, const char *what,\n+\t\t\tstruct strbuf *sb, const char *line,\n+\t\t\tconst char *encoding);\n+void pp_title_line(struct pretty_print_context *pp, const char **msg_p,\n+\t\t\tstruct strbuf *sb, const char *encoding,\n+\t\t\tint need_8bit_cte);\n+void pp_remainder(struct pretty_print_context *pp, const char **msg_p,\n+\t\t\tstruct strbuf *sb, int indent);\n+\n+void format_commit_message(const struct commit *commit,\n+\t\t\tconst char *format, struct strbuf *sb,\n+\t\t\tconst struct pretty_print_context *context);\n+\n+void get_commit_format(const char *arg, struct rev_info *);\n+\n+void pretty_print_commit(struct pretty_print_context *pp,\n+\t\t\tconst struct commit *commit,\n+\t\t\tstruct strbuf *sb);\n+\n+const char *format_subject(struct strbuf *sb, const char *msg,\n+\t\t\tconst char *line_separator);\n+\n+int commit_format_is_empty(enum cmit_fmt);\n+\n+#endif /* PRETTY_H */\ndiff --git a/revision.h b/revision.h\nindex 54761200adf2d..747bce8d8a184 100644\n--- a/revision.h\n+++ b/revision.h\n@@ -4,7 +4,7 @@\n #include \"parse-options.h\"\n #include \"grep.h\"\n #include \"notes.h\"\n-#include \"commit.h\"\n+#include \"pretty.h\"\n #include \"diff.h\"\n \n /* Remember to update object flag allocation in object.h */\ndiff --git a/sequencer.c b/sequencer.c\nindex fa94ed652d2ce..654d577ca3cc7 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -5,6 +5,7 @@\n #include \"dir.h\"\n #include \"object.h\"\n #include \"commit.h\"\n+#include \"pretty.h\"\n #include \"tag.h\"\n #include \"run-command.h\"\n #include \"exec_cmd.h\"\ndiff --git a/sha1_name.c b/sha1_name.c\nindex 611c7d24ddee6..d35917612c8e7 100644\n--- a/sha1_name.c\n+++ b/sha1_name.c\n@@ -2,6 +2,7 @@\n #include \"config.h\"\n #include \"tag.h\"\n #include \"commit.h\"\n+#include \"pretty.h\"\n #include \"tree.h\"\n #include \"blob.h\"\n #include \"tree-walk.h\"\ndiff --git a/submodule.c b/submodule.c\nindex 95e6aff2bb74e..c05db7a45d9fe 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -6,6 +6,7 @@\n #include \"dir.h\"\n #include \"diff.h\"\n #include \"commit.h\"\n+#include \"pretty.h\"\n #include \"revision.h\"\n #include \"run-command.h\"\n #include \"diffcore.h\"\n\n--\nhttps://github.com/git/git/pull/439\n"},{"id":"334464","messageId":"xmqq7etx9kzq.fsf@gitster.mtv.corp.google.com","threadId":"47408","inReplyTo":"01020160364a23d5-471a2fd0-9fff-4599-86f8-b2f37a4a0a84-000000@eu-west-1.amazonses.com","subject":"Re: [PATCH Outreachy 1/2] format: create pretty.h file","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-12-08T17:40:09Z","receivedAt":"2017-12-08T17:40:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Olga Telezhnaya <olyatelezhnaya@gmail.com> writes:\n\n> -extern void get_commit_format(const char *arg, struct rev_info *);\n> -extern const char *format_subject(struct strbuf *sb, const char *msg,\n> -\t\t\t\t  const char *line_separator);\n> -extern void userformat_find_requirements(const char *fmt, struct userformat_want *w);\n> -extern int commit_format_is_empty(enum cmit_fmt);\n>  extern const char *skip_blank_lines(const char *msg);\n> -extern void format_commit_message(const struct commit *commit,\n> -\t\t\t\t  const char *format, struct strbuf *sb,\n> -\t\t\t\t  const struct pretty_print_context *context);\n> -extern void pretty_print_commit(struct pretty_print_context *pp,\n> -\t\t\t\tconst struct commit *commit,\n> -\t\t\t\tstruct strbuf *sb);\n> -extern void pp_commit_easy(enum cmit_fmt fmt, const struct commit *commit,\n> -\t\t\t   struct strbuf *sb);\n> -void pp_user_info(struct pretty_print_context *pp,\n> -\t\t  const char *what, struct strbuf *sb,\n> -\t\t  const char *line, const char *encoding);\n> -void pp_title_line(struct pretty_print_context *pp,\n> -\t\t   const char **msg_p,\n> -\t\t   struct strbuf *sb,\n> -\t\t   const char *encoding,\n> -\t\t   int need_8bit_cte);\n> -void pp_remainder(struct pretty_print_context *pp,\n> -\t\t  const char **msg_p,\n> -\t\t  struct strbuf *sb,\n> -\t\t  int indent);\n> ...\n> +void userformat_find_requirements(const char *fmt, struct userformat_want *w);\n> +void pp_commit_easy(enum cmit_fmt fmt, const struct commit *commit,\n> +\t\t\tstruct strbuf *sb);\n> +void pp_user_info(struct pretty_print_context *pp, const char *what,\n> +\t\t\tstruct strbuf *sb, const char *line,\n> +\t\t\tconst char *encoding);\n> +void pp_title_line(struct pretty_print_context *pp, const char **msg_p,\n> +\t\t\tstruct strbuf *sb, const char *encoding,\n> +\t\t\tint need_8bit_cte);\n> +void pp_remainder(struct pretty_print_context *pp, const char **msg_p,\n> +\t\t\tstruct strbuf *sb, int indent);\n> +\n> +void format_commit_message(const struct commit *commit,\n> +\t\t\tconst char *format, struct strbuf *sb,\n> +\t\t\tconst struct pretty_print_context *context);\n> +\n> +void get_commit_format(const char *arg, struct rev_info *);\n> +\n> +void pretty_print_commit(struct pretty_print_context *pp,\n> +\t\t\tconst struct commit *commit,\n> +\t\t\tstruct strbuf *sb);\n> +\n> +const char *format_subject(struct strbuf *sb, const char *msg,\n> +\t\t\tconst char *line_separator);\n> +\n> +int commit_format_is_empty(enum cmit_fmt);\n\nI see you've \"standardized\" to drop \"extern\" from the declarations\nin the header; I have an impression that our preference however is\nto go in the other direction.\n\nThe choice of bits that are moved to the new header looks quite\nsensible to me.\n\nThanks.\n"},{"id":"334474","messageId":"CAPig+cStPiUoqO1pRqJ7X679ALM+UhufJ5vhrRQ1j5fwoMtCJQ@mail.gmail.com","threadId":"47408","inReplyTo":"01020160364a23d5-471a2fd0-9fff-4599-86f8-b2f37a4a0a84-000000@eu-west-1.amazonses.com","subject":"Re: [PATCH Outreachy 1/2] format: create pretty.h file","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2017-12-08T18:11:46Z","receivedAt":"2017-12-08T18:11:55Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Fri, Dec 8, 2017 at 8:21 AM, Olga Telezhnaya\n<olyatelezhnaya@gmail.com> wrote:\n> Create header for pretty.c to make formatting interface more structured.\n> This is a middle point, this file would be merged futher with other\n\ns/futher/further/\n\n> files which contain formatting stuff.\n>\n> Signed-off-by: Olga Telezhnaia <olyatelezhnaya@gmail.com>\n> Mentored-by: Christian Couder <christian.couder@gmail.com>\n> Mentored by: Jeff King <peff@peff.net>\n"},{"id":"334481","messageId":"CAPig+cSjSHJoBz5rWBZE=AO=XhEk6ZoGkmqiuk_r9PgAe5wt4w@mail.gmail.com","threadId":"47408","inReplyTo":"01020160364a2471-0e40e237-80b4-485c-a987-9c83206a2ee5-000000@eu-west-1.amazonses.com","subject":"Re: [PATCH Outreachy 2/2] format: create docs for pretty.h","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2017-12-08T19:26:23Z","receivedAt":"2017-12-08T19:26:29Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Fri, Dec 8, 2017 at 8:21 AM, Olga Telezhnaya\n<olyatelezhnaya@gmail.com> wrote:\n> Write some docs for functions in pretty.h.\n> Take it as a first draft, they would be changed later.\n>\n> Signed-off-by: Olga Telezhnaia <olyatelezhnaya@gmail.com>\n> Mentored-by: Christian Couder <christian.couder@gmail.com>\n> Mentored by: Jeff King <peff@peff.net>\n> ---\n> diff --git a/pretty.h b/pretty.h\n> @@ -57,31 +58,74 @@ struct userformat_want {\n> +/*\n> + * Create a text message about commit using given \"format\" and \"context\".\n> + * Put the result to \"sb\".\n> + * Please use this function for custom formats.\n> + */\n>  void format_commit_message(const struct commit *commit,\n>                         const char *format, struct strbuf *sb,\n>                         const struct pretty_print_context *context);\n>\n> +/*\n> + * Parse given arguments from \"arg\", check it for correctness and\n> + * fill struct rev_info.\n\nTo be consistent with the way you formatted the other comments, I\nthink you'd want quotes around rev_info.\n\n> + */\n>  void get_commit_format(const char *arg, struct rev_info *);\n"},{"id":"334494","messageId":"xmqqr2s56jn6.fsf@gitster.mtv.corp.google.com","threadId":"47408","inReplyTo":"01020160364a23d5-471a2fd0-9fff-4599-86f8-b2f37a4a0a84-000000@eu-west-1.amazonses.com","subject":"Re: [PATCH Outreachy 1/2] format: create pretty.h file","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-12-08T20:37:33Z","receivedAt":"2017-12-08T20:37:41Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Olga Telezhnaya <olyatelezhnaya@gmail.com> writes:\n\n>  archive.c             |  1 +\n>  builtin/notes.c       |  2 +-\n>  builtin/reset.c       |  2 +-\n>  builtin/show-branch.c |  2 +-\n>  combine-diff.c        |  1 +\n>  commit.c              |  1 +\n>  commit.h              | 80 ----------------------------------------------\n>  diffcore-pickaxe.c    |  1 +\n>  grep.c                |  1 +\n>  log-tree.c            |  1 +\n>  notes-cache.c         |  1 +\n>  pretty.h              | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++\n>  revision.h            |  2 +-\n>  sequencer.c           |  1 +\n>  sha1_name.c           |  1 +\n>  submodule.c           |  1 +\n>  16 files changed, 101 insertions(+), 84 deletions(-)\n>  create mode 100644 pretty.h\n>\n> diff --git a/archive.c b/archive.c\n> index 0b7b62af0c3ec..60607e8c00857 100644\n> --- a/archive.c\n> +++ b/archive.c\n> @@ -2,6 +2,7 @@\n>  #include \"config.h\"\n>  #include \"refs.h\"\n>  #include \"commit.h\"\n> +#include \"pretty.h\"\n>  #include \"tree-walk.h\"\n>  #include \"attr.h\"\n>  #include \"archive.h\"\n\nThis has a toll on topics in flight that expect the symbols for\npretty are available in \"commit.h\"; they are forced to include\nthis new file they did not even know about.\n\nI notice that \"commit.h\" is included in \"builtin.h\"; perhaps adding\na new include for \"pretty.h\" there would be of lessor impact?  I\ndunno.\n\n"},{"id":"334528","messageId":"CAL21BmmPNFAGnjtJy_ULBPjeU9HJAVx3x8B4ZrbqKaq_MU4W0Q@mail.gmail.com","threadId":"47408","inReplyTo":"xmqqr2s56jn6.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH Outreachy 1/2] format: create pretty.h file","fromName":"Оля Тележная","fromEmail":"olyatelezhnaya@gmail.com","sentAt":"2017-12-09T07:48:39Z","receivedAt":"2017-12-09T07:48:47Z","isPatch":true,"sender":{"key":"olyatelezhnaya@gmail.com","avatar":"https://avatars.githubusercontent.com/u/11246099?v=4"},"body":"> I see you've \"standardized\" to drop \"extern\" from the declarations\n> in the header; I have an impression that our preference however is\n> to go in the other direction.\n\nOK, absolutely not a problem, I will return them. Do I need to write\n\"extern\" further in function declarations? And why did everyone choose\nwriting \"extern\" every time? It looks obvious for me that declaration\nof function is extern, that's why I decided to throw them away.\n\n\n> The choice of bits that are moved to the new header looks quite\n> sensible to me.\n\nI'm very happy and satisfied with it :-)\n\n\n> s/futher/further/\n\nIt was a typo that I missed. Thank you! Will fix it also.\n\n\n> This has a toll on topics in flight that expect the symbols for\n> pretty are available in \"commit.h\"; they are forced to include\n> this new file they did not even know about.\n>\n> I notice that \"commit.h\" is included in \"builtin.h\"; perhaps adding\n> a new include for \"pretty.h\" there would be of lessor impact?  I\n> dunno.\n>\n\nIt's a middle point, as I said. I have plans to create unifying\nformat.h then (for all formatting issues). I guess that pretty.h and\nref-filter.h will be deleted later. But, I really need to create now\nthat pretty.h because it is much easier to work with existing\ninterface. If you have another ideas how to achieve the main goal -\nplease share them with me, I would appreciate that so much. I am not\nsure that my solution is the best, but I can't come up with something\nbetter for now.\n"},{"id":"334568","messageId":"20171210145354.GA20367@sigill.intra.peff.net","threadId":"47408","inReplyTo":"xmqq7etx9kzq.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH Outreachy 1/2] format: create pretty.h file","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-12-10T14:53:54Z","receivedAt":"2017-12-10T14:54:01Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Dec 08, 2017 at 09:40:09AM -0800, Junio C Hamano wrote:\n\n> I see you've \"standardized\" to drop \"extern\" from the declarations\n> in the header; I have an impression that our preference however is\n> to go in the other direction.\n\nCan we revisit that?\n\nI haven't see any compelling reason to include the \"extern\" in a\ndeclaration. And all things being equal, I'd prefer the thing that makes\nthe source code shorter, and is one less thing for authors to remember\nto do.\n\n-Peff\n"},{"id":"334582","messageId":"xmqq8tea5hxi.fsf@gitster.mtv.corp.google.com","threadId":"47408","inReplyTo":"20171210145354.GA20367@sigill.intra.peff.net","subject":"Re: [PATCH Outreachy 1/2] format: create pretty.h file","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-12-10T22:36:41Z","receivedAt":"2017-12-10T22:36:49Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> On Fri, Dec 08, 2017 at 09:40:09AM -0800, Junio C Hamano wrote:\n>\n>> I see you've \"standardized\" to drop \"extern\" from the declarations\n>> in the header; I have an impression that our preference however is\n>> to go in the other direction.\n>\n> Can we revisit that?\n>\n> I haven't see any compelling reason to include the \"extern\" in a\n> declaration. And all things being equal, I'd prefer the thing that makes\n> the source code shorter, and is one less thing for authors to remember\n> to do.\n\nSurely, but there is no point revisiting.  I simply misremembered\nwhat we did at around 1354c9b2 (\"refs: remove unnecessary \"extern\"\nkeywords\", 2016-03-31).\n\nAs long as we know which way we are standardizing, I personally do\nnot have strong preference either way.  I appreciate shorter-to-type\n(i.e. missing \"extern\") but I also appreciate the more familiar and\nlogical declaration in a header file that indicates something exists\nsomewhere (i.e. explicit \"extern\") ;-).\n\nThanks.\n"},{"id":"334592","messageId":"CAL21Bmnq63BNGwbkgbSpY-G+GMYBG4UC9+-YL1Gru84Be3EkeA@mail.gmail.com","threadId":"47408","inReplyTo":"xmqq8tea5hxi.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH Outreachy 1/2] format: create pretty.h file","fromName":"Оля Тележная","fromEmail":"olyatelezhnaya@gmail.com","sentAt":"2017-12-11T09:58:05Z","receivedAt":"2017-12-11T09:58:21Z","isPatch":true,"sender":{"key":"olyatelezhnaya@gmail.com","avatar":"https://avatars.githubusercontent.com/u/11246099?v=4"},"body":"Is it true that I need to fix only one commit message? (a typo\ns/futher/further/)\n\nDo you have any other advises what do I need to change?\n\nThanks!\n"},{"id":"334629","messageId":"xmqqzi6p3sih.fsf@gitster.mtv.corp.google.com","threadId":"47408","inReplyTo":"CAL21Bmnq63BNGwbkgbSpY-G+GMYBG4UC9+-YL1Gru84Be3EkeA@mail.gmail.com","subject":"Re: [PATCH Outreachy 1/2] format: create pretty.h file","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-12-11T20:43:18Z","receivedAt":"2017-12-11T20:43:26Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Оля Тележная  <olyatelezhnaya@gmail.com> writes:\n\n> Is it true that I need to fix only one commit message? (a typo\n> s/futher/further/)\n>\n> Do you have any other advises what do I need to change?\n\nI thought I mentioned that adding #include to all the current users\nof \"commit.h\" is way too noisy.  I may have pointed out other issues\nas well, but I offhand do not remember ;-)\n"},{"id":"334664","messageId":"0102016049efb7b4-b8dc7cff-5ddf-4692-ba1c-3551720ec28d-000000@eu-west-1.amazonses.com","threadId":"47408","inReplyTo":"01020160364a23d5-471a2fd0-9fff-4599-86f8-b2f37a4a0a84-000000@eu-west-1.amazonses.com","subject":"[PATCH Outreachy v2 1/2] format: create pretty.h file","fromName":"Olga Telezhnaya","fromEmail":"olyatelezhnaya@gmail.com","sentAt":"2017-12-12T08:55:35Z","receivedAt":"2017-12-12T08:55:44Z","isPatch":true,"sender":{"key":"olyatelezhnaya@gmail.com","avatar":"https://avatars.githubusercontent.com/u/11246099?v=4"},"body":"Create header for pretty.c to make formatting interface more structured.\nThis is a middle point, this file would be merged further with other\nfiles which contain formatting stuff.\n\nSigned-off-by: Olga Telezhnaia <olyatelezhnaya@gmail.com>\nMentored-by: Christian Couder <christian.couder@gmail.com>\nMentored by: Jeff King <peff@peff.net>\n---\n builtin/notes.c       |  2 +-\n builtin/reset.c       |  2 +-\n builtin/show-branch.c |  2 +-\n commit.h              | 81 +----------------------------------------------\n pretty.h              | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++\n revision.h            |  2 +-\n 6 files changed, 92 insertions(+), 84 deletions(-)\n create mode 100644 pretty.h\n\ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex 1a2c7d92ad7e7..7c8176164561b 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -12,7 +12,7 @@\n #include \"builtin.h\"\n #include \"notes.h\"\n #include \"blob.h\"\n-#include \"commit.h\"\n+#include \"pretty.h\"\n #include \"refs.h\"\n #include \"exec_cmd.h\"\n #include \"run-command.h\"\ndiff --git a/builtin/reset.c b/builtin/reset.c\nindex 906e541658230..e15f595799c40 100644\n--- a/builtin/reset.c\n+++ b/builtin/reset.c\n@@ -12,7 +12,7 @@\n #include \"lockfile.h\"\n #include \"tag.h\"\n #include \"object.h\"\n-#include \"commit.h\"\n+#include \"pretty.h\"\n #include \"run-command.h\"\n #include \"refs.h\"\n #include \"diff.h\"\ndiff --git a/builtin/show-branch.c b/builtin/show-branch.c\nindex 2e24b5c330e8e..e8a4aa40cb4b6 100644\n--- a/builtin/show-branch.c\n+++ b/builtin/show-branch.c\n@@ -1,6 +1,6 @@\n #include \"cache.h\"\n #include \"config.h\"\n-#include \"commit.h\"\n+#include \"pretty.h\"\n #include \"refs.h\"\n #include \"builtin.h\"\n #include \"color.h\"\ndiff --git a/commit.h b/commit.h\nindex 99a3fea68d3f6..8c68ca1a5a187 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -7,6 +7,7 @@\n #include \"decorate.h\"\n #include \"gpg-interface.h\"\n #include \"string-list.h\"\n+#include \"pretty.h\"\n \n struct commit_list {\n \tstruct commit *item;\n@@ -121,93 +122,13 @@ struct commit_list *copy_commit_list(struct commit_list *list);\n \n void free_commit_list(struct commit_list *list);\n \n-/* Commit formats */\n-enum cmit_fmt {\n-\tCMIT_FMT_RAW,\n-\tCMIT_FMT_MEDIUM,\n-\tCMIT_FMT_DEFAULT = CMIT_FMT_MEDIUM,\n-\tCMIT_FMT_SHORT,\n-\tCMIT_FMT_FULL,\n-\tCMIT_FMT_FULLER,\n-\tCMIT_FMT_ONELINE,\n-\tCMIT_FMT_EMAIL,\n-\tCMIT_FMT_MBOXRD,\n-\tCMIT_FMT_USERFORMAT,\n-\n-\tCMIT_FMT_UNSPECIFIED\n-};\n-\n-static inline int cmit_fmt_is_mail(enum cmit_fmt fmt)\n-{\n-\treturn (fmt == CMIT_FMT_EMAIL || fmt == CMIT_FMT_MBOXRD);\n-}\n-\n struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */\n \n-struct pretty_print_context {\n-\t/*\n-\t * Callers should tweak these to change the behavior of pp_* functions.\n-\t */\n-\tenum cmit_fmt fmt;\n-\tint abbrev;\n-\tconst char *after_subject;\n-\tint preserve_subject;\n-\tstruct date_mode date_mode;\n-\tunsigned date_mode_explicit:1;\n-\tint print_email_subject;\n-\tint expand_tabs_in_log;\n-\tint need_8bit_cte;\n-\tchar *notes_message;\n-\tstruct reflog_walk_info *reflog_info;\n-\tstruct rev_info *rev;\n-\tconst char *output_encoding;\n-\tstruct string_list *mailmap;\n-\tint color;\n-\tstruct ident_split *from_ident;\n-\n-\t/*\n-\t * Fields below here are manipulated internally by pp_* functions and\n-\t * should not be counted on by callers.\n-\t */\n-\tstruct string_list in_body_headers;\n-\tint graph_width;\n-};\n-\n-struct userformat_want {\n-\tunsigned notes:1;\n-};\n-\n extern int has_non_ascii(const char *text);\n extern const char *logmsg_reencode(const struct commit *commit,\n \t\t\t\t   char **commit_encoding,\n \t\t\t\t   const char *output_encoding);\n-extern void get_commit_format(const char *arg, struct rev_info *);\n-extern const char *format_subject(struct strbuf *sb, const char *msg,\n-\t\t\t\t  const char *line_separator);\n-extern void userformat_find_requirements(const char *fmt, struct userformat_want *w);\n-extern int commit_format_is_empty(enum cmit_fmt);\n extern const char *skip_blank_lines(const char *msg);\n-extern void format_commit_message(const struct commit *commit,\n-\t\t\t\t  const char *format, struct strbuf *sb,\n-\t\t\t\t  const struct pretty_print_context *context);\n-extern void pretty_print_commit(struct pretty_print_context *pp,\n-\t\t\t\tconst struct commit *commit,\n-\t\t\t\tstruct strbuf *sb);\n-extern void pp_commit_easy(enum cmit_fmt fmt, const struct commit *commit,\n-\t\t\t   struct strbuf *sb);\n-void pp_user_info(struct pretty_print_context *pp,\n-\t\t  const char *what, struct strbuf *sb,\n-\t\t  const char *line, const char *encoding);\n-void pp_title_line(struct pretty_print_context *pp,\n-\t\t   const char **msg_p,\n-\t\t   struct strbuf *sb,\n-\t\t   const char *encoding,\n-\t\t   int need_8bit_cte);\n-void pp_remainder(struct pretty_print_context *pp,\n-\t\t  const char **msg_p,\n-\t\t  struct strbuf *sb,\n-\t\t  int indent);\n-\n \n /** Removes the first commit from a list sorted by date, and adds all\n  * of its parents.\ndiff --git a/pretty.h b/pretty.h\nnew file mode 100644\nindex 0000000000000..ef5167484fb64\n--- /dev/null\n+++ b/pretty.h\n@@ -0,0 +1,87 @@\n+#ifndef PRETTY_H\n+#define PRETTY_H\n+\n+struct commit;\n+\n+/* Commit formats */\n+enum cmit_fmt {\n+\tCMIT_FMT_RAW,\n+\tCMIT_FMT_MEDIUM,\n+\tCMIT_FMT_DEFAULT = CMIT_FMT_MEDIUM,\n+\tCMIT_FMT_SHORT,\n+\tCMIT_FMT_FULL,\n+\tCMIT_FMT_FULLER,\n+\tCMIT_FMT_ONELINE,\n+\tCMIT_FMT_EMAIL,\n+\tCMIT_FMT_MBOXRD,\n+\tCMIT_FMT_USERFORMAT,\n+\n+\tCMIT_FMT_UNSPECIFIED\n+};\n+\n+struct pretty_print_context {\n+\t/*\n+\t * Callers should tweak these to change the behavior of pp_* functions.\n+\t */\n+\tenum cmit_fmt fmt;\n+\tint abbrev;\n+\tconst char *after_subject;\n+\tint preserve_subject;\n+\tstruct date_mode date_mode;\n+\tunsigned date_mode_explicit:1;\n+\tint print_email_subject;\n+\tint expand_tabs_in_log;\n+\tint need_8bit_cte;\n+\tchar *notes_message;\n+\tstruct reflog_walk_info *reflog_info;\n+\tstruct rev_info *rev;\n+\tconst char *output_encoding;\n+\tstruct string_list *mailmap;\n+\tint color;\n+\tstruct ident_split *from_ident;\n+\n+\t/*\n+\t * Fields below here are manipulated internally by pp_* functions and\n+\t * should not be counted on by callers.\n+\t */\n+\tstruct string_list in_body_headers;\n+\tint graph_width;\n+};\n+\n+static inline int cmit_fmt_is_mail(enum cmit_fmt fmt)\n+{\n+\treturn (fmt == CMIT_FMT_EMAIL || fmt == CMIT_FMT_MBOXRD);\n+}\n+\n+struct userformat_want {\n+\tunsigned notes:1;\n+};\n+\n+void userformat_find_requirements(const char *fmt, struct userformat_want *w);\n+void pp_commit_easy(enum cmit_fmt fmt, const struct commit *commit,\n+\t\t\tstruct strbuf *sb);\n+void pp_user_info(struct pretty_print_context *pp, const char *what,\n+\t\t\tstruct strbuf *sb, const char *line,\n+\t\t\tconst char *encoding);\n+void pp_title_line(struct pretty_print_context *pp, const char **msg_p,\n+\t\t\tstruct strbuf *sb, const char *encoding,\n+\t\t\tint need_8bit_cte);\n+void pp_remainder(struct pretty_print_context *pp, const char **msg_p,\n+\t\t\tstruct strbuf *sb, int indent);\n+\n+void format_commit_message(const struct commit *commit,\n+\t\t\tconst char *format, struct strbuf *sb,\n+\t\t\tconst struct pretty_print_context *context);\n+\n+void get_commit_format(const char *arg, struct rev_info *);\n+\n+void pretty_print_commit(struct pretty_print_context *pp,\n+\t\t\tconst struct commit *commit,\n+\t\t\tstruct strbuf *sb);\n+\n+const char *format_subject(struct strbuf *sb, const char *msg,\n+\t\t\tconst char *line_separator);\n+\n+int commit_format_is_empty(enum cmit_fmt);\n+\n+#endif /* PRETTY_H */\ndiff --git a/revision.h b/revision.h\nindex 54761200adf2d..747bce8d8a184 100644\n--- a/revision.h\n+++ b/revision.h\n@@ -4,7 +4,7 @@\n #include \"parse-options.h\"\n #include \"grep.h\"\n #include \"notes.h\"\n-#include \"commit.h\"\n+#include \"pretty.h\"\n #include \"diff.h\"\n \n /* Remember to update object flag allocation in object.h */\n\n--\nhttps://github.com/git/git/pull/439\n"},{"id":"334665","messageId":"0102016049efb823-20513044-7d28-4a27-bbd7-164c05de0b25-000000@eu-west-1.amazonses.com","threadId":"47408","inReplyTo":"0102016049efb7b4-b8dc7cff-5ddf-4692-ba1c-3551720ec28d-000000@eu-west-1.amazonses.com","subject":"[PATCH Outreachy v2 2/2] format: create docs for pretty.h","fromName":"Olga Telezhnaya","fromEmail":"olyatelezhnaya@gmail.com","sentAt":"2017-12-12T08:55:35Z","receivedAt":"2017-12-12T08:55:47Z","isPatch":true,"sender":{"key":"olyatelezhnaya@gmail.com","avatar":"https://avatars.githubusercontent.com/u/11246099?v=4"},"body":"Write some docs for functions in pretty.h.\nTake it as a first draft, they would be changed later.\n\nSigned-off-by: Olga Telezhnaia <olyatelezhnaya@gmail.com>\nMentored-by: Christian Couder <christian.couder@gmail.com>\nMentored by: Jeff King <peff@peff.net>\n---\n pretty.h | 44 ++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 44 insertions(+)\n\ndiff --git a/pretty.h b/pretty.h\nindex ef5167484fb64..5c85d94e332d7 100644\n--- a/pretty.h\n+++ b/pretty.h\n@@ -48,6 +48,7 @@ struct pretty_print_context {\n \tint graph_width;\n };\n \n+/* Check whether commit format is mail. */\n static inline int cmit_fmt_is_mail(enum cmit_fmt fmt)\n {\n \treturn (fmt == CMIT_FMT_EMAIL || fmt == CMIT_FMT_MBOXRD);\n@@ -57,31 +58,74 @@ struct userformat_want {\n \tunsigned notes:1;\n };\n \n+/* Set the flag \"w->notes\" if there is placeholder %N in \"fmt\". */\n void userformat_find_requirements(const char *fmt, struct userformat_want *w);\n+\n+/*\n+ * Shortcut for invoking pretty_print_commit if we do not have any context.\n+ * Context would be set empty except \"fmt\".\n+ */\n void pp_commit_easy(enum cmit_fmt fmt, const struct commit *commit,\n \t\t\tstruct strbuf *sb);\n+\n+/*\n+ * Get information about user and date from \"line\", format it and\n+ * put it into \"sb\".\n+ * Format of \"line\" must be readable for split_ident_line function.\n+ * The resulting format is \"what: name <email> date\".\n+ */\n void pp_user_info(struct pretty_print_context *pp, const char *what,\n \t\t\tstruct strbuf *sb, const char *line,\n \t\t\tconst char *encoding);\n+\n+/*\n+ * Format title line of commit message taken from \"msg_p\" and\n+ * put it into \"sb\".\n+ * First line of \"msg_p\" is also affected.\n+ */\n void pp_title_line(struct pretty_print_context *pp, const char **msg_p,\n \t\t\tstruct strbuf *sb, const char *encoding,\n \t\t\tint need_8bit_cte);\n+\n+/*\n+ * Get current state of commit message from \"msg_p\" and continue formatting\n+ * by adding indentation and '>' signs. Put result into \"sb\".\n+ */\n void pp_remainder(struct pretty_print_context *pp, const char **msg_p,\n \t\t\tstruct strbuf *sb, int indent);\n \n+/*\n+ * Create a text message about commit using given \"format\" and \"context\".\n+ * Put the result to \"sb\".\n+ * Please use this function for custom formats.\n+ */\n void format_commit_message(const struct commit *commit,\n \t\t\tconst char *format, struct strbuf *sb,\n \t\t\tconst struct pretty_print_context *context);\n \n+/*\n+ * Parse given arguments from \"arg\", check it for correctness and\n+ * fill struct rev_info.\n+ */\n void get_commit_format(const char *arg, struct rev_info *);\n \n+/*\n+ * Make a commit message with all rules from given \"pp\"\n+ * and put it into \"sb\".\n+ * Please use this function if you have a context (candidate for \"pp\").\n+ */\n void pretty_print_commit(struct pretty_print_context *pp,\n \t\t\tconst struct commit *commit,\n \t\t\tstruct strbuf *sb);\n \n+/*\n+ * Change line breaks in \"msg\" to \"line_separator\" and put it into \"sb\".\n+ * Return \"msg\" itself.\n+ */\n const char *format_subject(struct strbuf *sb, const char *msg,\n \t\t\tconst char *line_separator);\n \n+/* Check if \"cmit_fmt\" will produce an empty output. */\n int commit_format_is_empty(enum cmit_fmt);\n \n #endif /* PRETTY_H */\n\n--\nhttps://github.com/git/git/pull/439\n"},{"id":"334718","messageId":"xmqqh8svzjbx.fsf@gitster.mtv.corp.google.com","threadId":"47408","inReplyTo":"0102016049efb7b4-b8dc7cff-5ddf-4692-ba1c-3551720ec28d-000000@eu-west-1.amazonses.com","subject":"Re: [PATCH Outreachy v2 1/2] format: create pretty.h file","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-12-12T22:12:50Z","receivedAt":"2017-12-12T22:12:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Olga Telezhnaya <olyatelezhnaya@gmail.com> writes:\n\n>  builtin/notes.c       |  2 +-\n>  builtin/reset.c       |  2 +-\n>  builtin/show-branch.c |  2 +-\n>  commit.h              | 81 +----------------------------------------------\n>  pretty.h              | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++\n>  revision.h            |  2 +-\n>  6 files changed, 92 insertions(+), 84 deletions(-)\n>  create mode 100644 pretty.h\n>\n> diff --git a/builtin/notes.c b/builtin/notes.c\n> index 1a2c7d92ad7e7..7c8176164561b 100644\n> --- a/builtin/notes.c\n> +++ b/builtin/notes.c\n> @@ -12,7 +12,7 @@\n>  #include \"builtin.h\"\n>  #include \"notes.h\"\n>  #include \"blob.h\"\n> -#include \"commit.h\"\n> +#include \"pretty.h\"\n>  #include \"refs.h\"\n>  #include \"exec_cmd.h\"\n>  #include \"run-command.h\"\n> ...\n> diff --git a/commit.h b/commit.h\n> index 99a3fea68d3f6..8c68ca1a5a187 100644\n> --- a/commit.h\n> +++ b/commit.h\n> @@ -7,6 +7,7 @@\n>  #include \"decorate.h\"\n>  #include \"gpg-interface.h\"\n>  #include \"string-list.h\"\n> +#include \"pretty.h\"\n\nThis is much nicer than what I imagined, which was to just add this\nline here, move decls from commit.h to pretty.h, and do nothing\nelse, which would be the absolute safest thing from the point of\nview of other topics in flight.  Separation of \"pretty.h\" would stay\nto be an implementation detail of the \"commit.h\" file, where\neverybody expects to find these decls.\n\nInstead, this patch inspects each and every .c user of \"commit.h\"\nand replaces its '#include' with the new one if it only uses things\ndeclared in \"pretty.h\", which makes it very clear who have been\ndepending on what in the patch.  Those that include \"commit.h\"\nbecause they need both the \"what is a commit object\" aspect and \"how\nto pretty print\" aspect can keep using their original '#include' to\nease the transition.\n\nLet's see how well this plays with other topics in flight---I had to\napply an evil merge to queue the previous one, if I recall right, as\na user of \"commit.h\" that did not use pretty-print (hence did not\nget \"pretty.h\" with the previous round of this patch) gained use of\npretty-print function, or something like that.\n\nWill queue.\n\nThanks.\n\n \n"}]}