Windows ANSI - hook write()
[git/mingw/4msysgit/peterh.git] / graph.h
blobeab4e3daba9812293d4e005c3ebe28f9a97744ce
1 #ifndef GRAPH_H
2 #define GRAPH_H
4 /* A graph is a pointer to this opaque structure */
5 struct git_graph;
7 /*
8 * Create a new struct git_graph.
9 * The graph should be freed with graph_release() when no longer needed.
11 struct git_graph *graph_init(struct rev_info *opt);
14 * Destroy a struct git_graph and free associated memory.
16 void graph_release(struct git_graph *graph);
19 * Update a git_graph with a new commit.
20 * This will cause the graph to begin outputting lines for the new commit
21 * the next time graph_next_line() is called.
23 * If graph_update() is called before graph_is_commit_finished() returns 1,
24 * the next call to graph_next_line() will output an ellipsis ("...")
25 * to indicate that a portion of the graph is missing.
27 void graph_update(struct git_graph *graph, struct commit *commit);
30 * Output the next line for a graph.
31 * This formats the next graph line into the specified strbuf. It is not
32 * terminated with a newline.
34 * Returns 1 if the line includes the current commit, and 0 otherwise.
35 * graph_next_line() will return 1 exactly once for each time
36 * graph_update() is called.
38 int graph_next_line(struct git_graph *graph, struct strbuf *sb);
41 * Output a padding line in the graph.
42 * This is similar to graph_next_line(). However, it is guaranteed to
43 * never print the current commit line. Instead, if the commit line is
44 * next, it will simply output a line of vertical padding, extending the
45 * branch lines downwards, but leaving them otherwise unchanged.
47 void graph_padding_line(struct git_graph *graph, struct strbuf *sb);
50 * Determine if a graph has finished outputting lines for the current
51 * commit.
53 * Returns 1 if graph_next_line() needs to be called again before
54 * graph_update() should be called. Returns 0 if no more lines are needed
55 * for this commit. If 0 is returned, graph_next_line() may still be
56 * called without calling graph_update(), and it will merely output
57 * appropriate "vertical padding" in the graph.
59 int graph_is_commit_finished(struct git_graph const *graph);
63 * graph_show_*: helper functions for printing to stdout
68 * If the graph is non-NULL, print the history graph to stdout,
69 * up to and including the line containing this commit.
70 * Does not print a terminating newline on the last line.
72 void graph_show_commit(struct git_graph *graph);
75 * If the graph is non-NULL, print one line of the history graph to stdout.
76 * Does not print a terminating newline on the last line.
78 void graph_show_oneline(struct git_graph *graph);
81 * If the graph is non-NULL, print one line of vertical graph padding to
82 * stdout. Does not print a terminating newline on the last line.
84 void graph_show_padding(struct git_graph *graph);
87 * If the graph is non-NULL, print the rest of the history graph for this
88 * commit to stdout. Does not print a terminating newline on the last line.
90 int graph_show_remainder(struct git_graph *graph);
93 * Print a strbuf to stdout. If the graph is non-NULL, all lines but the
94 * first will be prefixed with the graph output.
96 * If the strbuf ends with a newline, the output will end after this
97 * newline. A new graph line will not be printed after the final newline.
98 * If the strbuf is empty, no output will be printed.
100 * Since the first line will not include the graph ouput, the caller is
101 * responsible for printing this line's graph (perhaps via
102 * graph_show_commit() or graph_show_oneline()) before calling
103 * graph_show_strbuf().
105 void graph_show_strbuf(struct git_graph *graph, struct strbuf const *sb);
108 * Print a commit message strbuf and the remainder of the graph to stdout.
110 * This is similar to graph_show_strbuf(), but it always prints the
111 * remainder of the graph.
113 * If the strbuf ends with a newline, the output printed by
114 * graph_show_commit_msg() will end with a newline. If the strbuf is
115 * missing a terminating newline (including if it is empty), the output
116 * printed by graph_show_commit_msg() will also be missing a terminating
117 * newline.
119 void graph_show_commit_msg(struct git_graph *graph, struct strbuf const *sb);
121 #endif /* GRAPH_H */