Skip to content

Commit d0e6326

Browse files
telezhnayagitster
authored andcommitted
format: create docs for pretty.h
Write some docs for functions in pretty.h. Take it as a first draft, they would be changed later. Signed-off-by: Olga Telezhnaia <[email protected]> Mentored-by: Christian Couder <[email protected]> Mentored by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent cf39471 commit d0e6326

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

pretty.h

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ struct pretty_print_context {
4848
int graph_width;
4949
};
5050

51+
/* Check whether commit format is mail. */
5152
static inline int cmit_fmt_is_mail(enum cmit_fmt fmt)
5253
{
5354
return (fmt == CMIT_FMT_EMAIL || fmt == CMIT_FMT_MBOXRD);
@@ -57,31 +58,74 @@ struct userformat_want {
5758
unsigned notes:1;
5859
};
5960

61+
/* Set the flag "w->notes" if there is placeholder %N in "fmt". */
6062
void userformat_find_requirements(const char *fmt, struct userformat_want *w);
63+
64+
/*
65+
* Shortcut for invoking pretty_print_commit if we do not have any context.
66+
* Context would be set empty except "fmt".
67+
*/
6168
void pp_commit_easy(enum cmit_fmt fmt, const struct commit *commit,
6269
struct strbuf *sb);
70+
71+
/*
72+
* Get information about user and date from "line", format it and
73+
* put it into "sb".
74+
* Format of "line" must be readable for split_ident_line function.
75+
* The resulting format is "what: name <email> date".
76+
*/
6377
void pp_user_info(struct pretty_print_context *pp, const char *what,
6478
struct strbuf *sb, const char *line,
6579
const char *encoding);
80+
81+
/*
82+
* Format title line of commit message taken from "msg_p" and
83+
* put it into "sb".
84+
* First line of "msg_p" is also affected.
85+
*/
6686
void pp_title_line(struct pretty_print_context *pp, const char **msg_p,
6787
struct strbuf *sb, const char *encoding,
6888
int need_8bit_cte);
89+
90+
/*
91+
* Get current state of commit message from "msg_p" and continue formatting
92+
* by adding indentation and '>' signs. Put result into "sb".
93+
*/
6994
void pp_remainder(struct pretty_print_context *pp, const char **msg_p,
7095
struct strbuf *sb, int indent);
7196

97+
/*
98+
* Create a text message about commit using given "format" and "context".
99+
* Put the result to "sb".
100+
* Please use this function for custom formats.
101+
*/
72102
void format_commit_message(const struct commit *commit,
73103
const char *format, struct strbuf *sb,
74104
const struct pretty_print_context *context);
75105

106+
/*
107+
* Parse given arguments from "arg", check it for correctness and
108+
* fill struct rev_info.
109+
*/
76110
void get_commit_format(const char *arg, struct rev_info *);
77111

112+
/*
113+
* Make a commit message with all rules from given "pp"
114+
* and put it into "sb".
115+
* Please use this function if you have a context (candidate for "pp").
116+
*/
78117
void pretty_print_commit(struct pretty_print_context *pp,
79118
const struct commit *commit,
80119
struct strbuf *sb);
81120

121+
/*
122+
* Change line breaks in "msg" to "line_separator" and put it into "sb".
123+
* Return "msg" itself.
124+
*/
82125
const char *format_subject(struct strbuf *sb, const char *msg,
83126
const char *line_separator);
84127

128+
/* Check if "cmit_fmt" will produce an empty output. */
85129
int commit_format_is_empty(enum cmit_fmt);
86130

87131
#endif /* PRETTY_H */

0 commit comments

Comments
 (0)