sub-process: move sub-process functions into separate files
[git/debian.git] / graph.h
blobaf623390b6058d16677bb81223b2038148d07a6d
1 #ifndef GRAPH_H
2 #define GRAPH_H
3 #include "diff.h"
5 /* A graph is a pointer to this opaque structure */
6 struct git_graph;
8 /*
9 * Called to setup global display of line_prefix diff option.
11 * Passed a diff_options structure which indicates the line_prefix and the
12 * file to output the prefix to. This is sort of a hack used so that the
13 * line_prefix will be honored by all flows which also honor "--graph"
14 * regardless of whether a graph has actually been setup. The normal graph
15 * flow will honor the exact diff_options passed, but a NULL graph will cause
16 * display of a line_prefix to stdout.
18 void graph_setup_line_prefix(struct diff_options *diffopt);
21 * Set up a custom scheme for column colors.
23 * The default column color scheme inserts ANSI color escapes to colorize
24 * the graph. The various color escapes are stored in an array of strings
25 * where each entry corresponds to a color, except for the last entry,
26 * which denotes the escape for resetting the color back to the default.
27 * When generating the graph, strings from this array are inserted before
28 * and after the various column characters.
30 * This function allows you to enable a custom array of color escapes.
31 * The 'colors_max' argument is the index of the last "reset" entry.
33 * This functions must be called BEFORE graph_init() is called.
35 * NOTE: This function isn't used in Git outside graph.c but it is used
36 * by CGit (http://git.zx2c4.com/cgit/) to use HTML for colors.
38 void graph_set_column_colors(const char **colors, unsigned short colors_max);
41 * Create a new struct git_graph.
43 struct git_graph *graph_init(struct rev_info *opt);
46 * Update a git_graph with a new commit.
47 * This will cause the graph to begin outputting lines for the new commit
48 * the next time graph_next_line() is called.
50 * If graph_update() is called before graph_is_commit_finished() returns 1,
51 * the next call to graph_next_line() will output an ellipsis ("...")
52 * to indicate that a portion of the graph is missing.
54 void graph_update(struct git_graph *graph, struct commit *commit);
57 * Determine if a graph has finished outputting lines for the current
58 * commit.
60 * Returns 1 if graph_next_line() needs to be called again before
61 * graph_update() should be called. Returns 0 if no more lines are needed
62 * for this commit. If 0 is returned, graph_next_line() may still be
63 * called without calling graph_update(), and it will merely output
64 * appropriate "vertical padding" in the graph.
66 int graph_is_commit_finished(struct git_graph const *graph);
69 * Output the next line for a graph.
70 * This formats the next graph line into the specified strbuf. It is not
71 * terminated with a newline.
73 * Returns 1 if the line includes the current commit, and 0 otherwise.
74 * graph_next_line() will return 1 exactly once for each time
75 * graph_update() is called.
77 * NOTE: This function isn't used in Git outside graph.c but it is used
78 * by CGit (http://git.zx2c4.com/cgit/) to wrap HTML around graph lines.
80 int graph_next_line(struct git_graph *graph, struct strbuf *sb);
84 * Return current width of the graph in on-screen characters.
86 int graph_width(struct git_graph *graph);
89 * graph_show_*: helper functions for printing to stdout
94 * If the graph is non-NULL, print the history graph to stdout,
95 * up to and including the line containing this commit.
96 * Does not print a terminating newline on the last line.
98 void graph_show_commit(struct git_graph *graph);
101 * If the graph is non-NULL, print one line of the history graph to stdout.
102 * Does not print a terminating newline on the last line.
104 void graph_show_oneline(struct git_graph *graph);
107 * If the graph is non-NULL, print one line of vertical graph padding to
108 * stdout. Does not print a terminating newline on the last line.
110 void graph_show_padding(struct git_graph *graph);
113 * If the graph is non-NULL, print the rest of the history graph for this
114 * commit to stdout. Does not print a terminating newline on the last line.
116 int graph_show_remainder(struct git_graph *graph);
119 * Print a commit message strbuf and the remainder of the graph to stdout.
121 * This is similar to graph_show_strbuf(), but it always prints the
122 * remainder of the graph.
124 * If the strbuf ends with a newline, the output printed by
125 * graph_show_commit_msg() will end with a newline. If the strbuf is
126 * missing a terminating newline (including if it is empty), the output
127 * printed by graph_show_commit_msg() will also be missing a terminating
128 * newline.
130 * Note that unlike some other graph display functions, you must pass the file
131 * handle directly. It is assumed that this is the same file handle as the
132 * file specified by the graph diff options. This is necessary so that
133 * graph_show_commit_msg can be called even with a NULL graph.
135 void graph_show_commit_msg(struct git_graph *graph,
136 FILE *file,
137 struct strbuf const *sb);
139 #endif /* GRAPH_H */