1#ifndef GRAPH_H 2#define GRAPH_H 3 4/* A graph is a pointer to this opaque structure */ 5struct git_graph; 6 7/* 8 * Create a new struct git_graph. 9 */ 10struct git_graph *graph_init(struct rev_info *opt); 11 12/* 13 * Update a git_graph with a new commit. 14 * This will cause the graph to begin outputting lines for the new commit 15 * the next time graph_next_line() is called. 16 * 17 * If graph_update() is called before graph_is_commit_finished() returns 1, 18 * the next call to graph_next_line() will output an ellipsis ("...") 19 * to indicate that a portion of the graph is missing. 20 */ 21void graph_update(struct git_graph *graph, struct commit *commit); 22 23/* 24 * Determine if a graph has finished outputting lines for the current 25 * commit. 26 * 27 * Returns 1 if graph_next_line() needs to be called again before 28 * graph_update() should be called. Returns 0 if no more lines are needed 29 * for this commit. If 0 is returned, graph_next_line() may still be 30 * called without calling graph_update(), and it will merely output 31 * appropriate "vertical padding" in the graph. 32 */ 33int graph_is_commit_finished(struct git_graph const *graph); 34 35/* 36 * Output the next line for a graph. 37 * This formats the next graph line into the specified strbuf. It is not 38 * terminated with a newline. 39 * 40 * Returns 1 if the line includes the current commit, and 0 otherwise. 41 * graph_next_line() will return 1 exactly once for each time 42 * graph_update() is called. 43 */ 44int graph_next_line(struct git_graph *graph, struct strbuf *sb); 45 46 47/* 48 * graph_show_*: helper functions for printing to stdout 49 */ 50 51 52/* 53 * If the graph is non-NULL, print the history graph to stdout, 54 * up to and including the line containing this commit. 55 * Does not print a terminating newline on the last line. 56 */ 57void graph_show_commit(struct git_graph *graph); 58 59/* 60 * If the graph is non-NULL, print one line of the history graph to stdout. 61 * Does not print a terminating newline on the last line. 62 */ 63void graph_show_oneline(struct git_graph *graph); 64 65/* 66 * If the graph is non-NULL, print one line of vertical graph padding to 67 * stdout. Does not print a terminating newline on the last line. 68 */ 69void graph_show_padding(struct git_graph *graph); 70 71/* 72 * If the graph is non-NULL, print the rest of the history graph for this 73 * commit to stdout. Does not print a terminating newline on the last line. 74 */ 75int graph_show_remainder(struct git_graph *graph); 76 77/* 78 * Print a commit message strbuf and the remainder of the graph to stdout. 79 * 80 * This is similar to graph_show_strbuf(), but it always prints the 81 * remainder of the graph. 82 * 83 * If the strbuf ends with a newline, the output printed by 84 * graph_show_commit_msg() will end with a newline. If the strbuf is 85 * missing a terminating newline (including if it is empty), the output 86 * printed by graph_show_commit_msg() will also be missing a terminating 87 * newline. 88 */ 89void graph_show_commit_msg(struct git_graph *graph, struct strbuf const *sb); 90 91#endif /* GRAPH_H */