Merge branch 'jc/maint-diff-patch-header' into maint
[git/debian.git] / graph.h
blobaff960c7e8f63f49e3ec16afb0b891cf257ce999
1 #ifndef GRAPH_H
2 #define GRAPH_H
4 /* A graph is a pointer to this opaque structure */
5 struct git_graph;
7 /*
8 * Set up a custom scheme for column colors.
10 * The default column color scheme inserts ANSI color escapes to colorize
11 * the graph. The various color escapes are stored in an array of strings
12 * where each entry corresponds to a color, except for the last entry,
13 * which denotes the escape for resetting the color back to the default.
14 * When generating the graph, strings from this array are inserted before
15 * and after the various column characters.
17 * This function allows you to enable a custom array of color escapes.
18 * The 'colors_max' argument is the index of the last "reset" entry.
20 * This functions must be called BEFORE graph_init() is called.
22 void graph_set_column_colors(const char **colors, unsigned short colors_max);
25 * Create a new struct git_graph.
27 struct git_graph *graph_init(struct rev_info *opt);
30 * Update a git_graph with a new commit.
31 * This will cause the graph to begin outputting lines for the new commit
32 * the next time graph_next_line() is called.
34 * If graph_update() is called before graph_is_commit_finished() returns 1,
35 * the next call to graph_next_line() will output an ellipsis ("...")
36 * to indicate that a portion of the graph is missing.
38 void graph_update(struct git_graph *graph, struct commit *commit);
41 * Determine if a graph has finished outputting lines for the current
42 * commit.
44 * Returns 1 if graph_next_line() needs to be called again before
45 * graph_update() should be called. Returns 0 if no more lines are needed
46 * for this commit. If 0 is returned, graph_next_line() may still be
47 * called without calling graph_update(), and it will merely output
48 * appropriate "vertical padding" in the graph.
50 int graph_is_commit_finished(struct git_graph const *graph);
53 * Output the next line for a graph.
54 * This formats the next graph line into the specified strbuf. It is not
55 * terminated with a newline.
57 * Returns 1 if the line includes the current commit, and 0 otherwise.
58 * graph_next_line() will return 1 exactly once for each time
59 * graph_update() is called.
61 int graph_next_line(struct git_graph *graph, struct strbuf *sb);
65 * graph_show_*: helper functions for printing to stdout
70 * If the graph is non-NULL, print the history graph to stdout,
71 * up to and including the line containing this commit.
72 * Does not print a terminating newline on the last line.
74 void graph_show_commit(struct git_graph *graph);
77 * If the graph is non-NULL, print one line of the history graph to stdout.
78 * Does not print a terminating newline on the last line.
80 void graph_show_oneline(struct git_graph *graph);
83 * If the graph is non-NULL, print one line of vertical graph padding to
84 * stdout. Does not print a terminating newline on the last line.
86 void graph_show_padding(struct git_graph *graph);
89 * If the graph is non-NULL, print the rest of the history graph for this
90 * commit to stdout. Does not print a terminating newline on the last line.
92 int graph_show_remainder(struct git_graph *graph);
95 * Print a commit message strbuf and the remainder of the graph to stdout.
97 * This is similar to graph_show_strbuf(), but it always prints the
98 * remainder of the graph.
100 * If the strbuf ends with a newline, the output printed by
101 * graph_show_commit_msg() will end with a newline. If the strbuf is
102 * missing a terminating newline (including if it is empty), the output
103 * printed by graph_show_commit_msg() will also be missing a terminating
104 * newline.
106 void graph_show_commit_msg(struct git_graph *graph, struct strbuf const *sb);
108 #endif /* GRAPH_H */