]> git.ipfire.org Git - thirdparty/git.git/blob - graph.h
revert: Introduce --continue to continue the operation
[thirdparty/git.git] / graph.h
1 #ifndef GRAPH_H
2 #define GRAPH_H
3
4 /* A graph is a pointer to this opaque structure */
5 struct git_graph;
6
7 /*
8 * Set up a custom scheme for column colors.
9 *
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.
16 *
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.
19 *
20 * This functions must be called BEFORE graph_init() is called.
21 */
22 void graph_set_column_colors(const char **colors, unsigned short colors_max);
23
24 /*
25 * Create a new struct git_graph.
26 */
27 struct git_graph *graph_init(struct rev_info *opt);
28
29 /*
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.
33 *
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.
37 */
38 void graph_update(struct git_graph *graph, struct commit *commit);
39
40 /*
41 * Determine if a graph has finished outputting lines for the current
42 * commit.
43 *
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.
49 */
50 int graph_is_commit_finished(struct git_graph const *graph);
51
52 /*
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.
56 *
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.
60 */
61 int graph_next_line(struct git_graph *graph, struct strbuf *sb);
62
63
64 /*
65 * graph_show_*: helper functions for printing to stdout
66 */
67
68
69 /*
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.
73 */
74 void graph_show_commit(struct git_graph *graph);
75
76 /*
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.
79 */
80 void graph_show_oneline(struct git_graph *graph);
81
82 /*
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.
85 */
86 void graph_show_padding(struct git_graph *graph);
87
88 /*
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.
91 */
92 int graph_show_remainder(struct git_graph *graph);
93
94 /*
95 * Print a commit message strbuf and the remainder of the graph to stdout.
96 *
97 * This is similar to graph_show_strbuf(), but it always prints the
98 * remainder of the graph.
99 *
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.
105 */
106 void graph_show_commit_msg(struct git_graph *graph, struct strbuf const *sb);
107
108 #endif /* GRAPH_H */