]> git.ipfire.org Git - thirdparty/git.git/blob - graph.h
GIT-VERSION-GEN: support non-standard $GIT_DIR path
[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 /*
9 * Create a new struct git_graph.
10 */
11 struct git_graph *graph_init(struct rev_info *opt);
12
13 /*
14 * Update a git_graph with a new commit.
15 * This will cause the graph to begin outputting lines for the new commit
16 * the next time graph_next_line() is called.
17 *
18 * If graph_update() is called before graph_is_commit_finished() returns 1,
19 * the next call to graph_next_line() will output an ellipsis ("...")
20 * to indicate that a portion of the graph is missing.
21 */
22 void graph_update(struct git_graph *graph, struct commit *commit);
23
24 /*
25 * Determine if a graph has finished outputting lines for the current
26 * commit.
27 *
28 * Returns 1 if graph_next_line() needs to be called again before
29 * graph_update() should be called. Returns 0 if no more lines are needed
30 * for this commit. If 0 is returned, graph_next_line() may still be
31 * called without calling graph_update(), and it will merely output
32 * appropriate "vertical padding" in the graph.
33 */
34 int graph_is_commit_finished(struct git_graph const *graph);
35
36
37 /*
38 * graph_show_*: helper functions for printing to stdout
39 */
40
41
42 /*
43 * If the graph is non-NULL, print the history graph to stdout,
44 * up to and including the line containing this commit.
45 * Does not print a terminating newline on the last line.
46 */
47 void graph_show_commit(struct git_graph *graph);
48
49 /*
50 * If the graph is non-NULL, print one line of the history graph to stdout.
51 * Does not print a terminating newline on the last line.
52 */
53 void graph_show_oneline(struct git_graph *graph);
54
55 /*
56 * If the graph is non-NULL, print one line of vertical graph padding to
57 * stdout. Does not print a terminating newline on the last line.
58 */
59 void graph_show_padding(struct git_graph *graph);
60
61 /*
62 * If the graph is non-NULL, print the rest of the history graph for this
63 * commit to stdout. Does not print a terminating newline on the last line.
64 */
65 int graph_show_remainder(struct git_graph *graph);
66
67 /*
68 * Print a commit message strbuf and the remainder of the graph to stdout.
69 *
70 * This is similar to graph_show_strbuf(), but it always prints the
71 * remainder of the graph.
72 *
73 * If the strbuf ends with a newline, the output printed by
74 * graph_show_commit_msg() will end with a newline. If the strbuf is
75 * missing a terminating newline (including if it is empty), the output
76 * printed by graph_show_commit_msg() will also be missing a terminating
77 * newline.
78 */
79 void graph_show_commit_msg(struct git_graph *graph, struct strbuf const *sb);
80
81 #endif /* GRAPH_H */