44#include "diff.h"
55#include "revision.h"
66
7+ /* Internal API */
8+
9+ /*
10+ * Output the next line for a graph.
11+ * This formats the next graph line into the specified strbuf. It is not
12+ * terminated with a newline.
13+ *
14+ * Returns 1 if the line includes the current commit, and 0 otherwise.
15+ * graph_next_line() will return 1 exactly once for each time
16+ * graph_update() is called.
17+ */
18+ static int graph_next_line (struct git_graph * graph , struct strbuf * sb );
19+
20+ /*
21+ * Output a padding line in the graph.
22+ * This is similar to graph_next_line(). However, it is guaranteed to
23+ * never print the current commit line. Instead, if the commit line is
24+ * next, it will simply output a line of vertical padding, extending the
25+ * branch lines downwards, but leaving them otherwise unchanged.
26+ */
27+ static void graph_padding_line (struct git_graph * graph , struct strbuf * sb );
28+
29+ /*
30+ * Print a strbuf to stdout. If the graph is non-NULL, all lines but the
31+ * first will be prefixed with the graph output.
32+ *
33+ * If the strbuf ends with a newline, the output will end after this
34+ * newline. A new graph line will not be printed after the final newline.
35+ * If the strbuf is empty, no output will be printed.
36+ *
37+ * Since the first line will not include the graph ouput, the caller is
38+ * responsible for printing this line's graph (perhaps via
39+ * graph_show_commit() or graph_show_oneline()) before calling
40+ * graph_show_strbuf().
41+ */
42+ static void graph_show_strbuf (struct git_graph * graph , struct strbuf const * sb );
43+
744/*
845 * TODO:
946 * - Add colors to the graph.
@@ -180,14 +217,6 @@ struct git_graph *graph_init(struct rev_info *opt)
180217 return graph ;
181218}
182219
183- void graph_release (struct git_graph * graph )
184- {
185- free (graph -> columns );
186- free (graph -> new_columns );
187- free (graph -> mapping );
188- free (graph );
189- }
190-
191220static void graph_update_state (struct git_graph * graph , enum graph_state s )
192221{
193222 graph -> prev_state = graph -> state ;
@@ -685,7 +714,7 @@ static void graph_output_commit_char(struct git_graph *graph, struct strbuf *sb)
685714 strbuf_addch (sb , '*' );
686715}
687716
688- void graph_output_commit_line (struct git_graph * graph , struct strbuf * sb )
717+ static void graph_output_commit_line (struct git_graph * graph , struct strbuf * sb )
689718{
690719 int seen_this = 0 ;
691720 int i , j ;
@@ -760,7 +789,7 @@ void graph_output_commit_line(struct git_graph *graph, struct strbuf *sb)
760789 graph_update_state (graph , GRAPH_COLLAPSING );
761790}
762791
763- void graph_output_post_merge_line (struct git_graph * graph , struct strbuf * sb )
792+ static void graph_output_post_merge_line (struct git_graph * graph , struct strbuf * sb )
764793{
765794 int seen_this = 0 ;
766795 int i , j ;
@@ -801,7 +830,7 @@ void graph_output_post_merge_line(struct git_graph *graph, struct strbuf *sb)
801830 graph_update_state (graph , GRAPH_COLLAPSING );
802831}
803832
804- void graph_output_collapsing_line (struct git_graph * graph , struct strbuf * sb )
833+ static void graph_output_collapsing_line (struct git_graph * graph , struct strbuf * sb )
805834{
806835 int i ;
807836 int * tmp_mapping ;
@@ -906,7 +935,7 @@ void graph_output_collapsing_line(struct git_graph *graph, struct strbuf *sb)
906935 graph_update_state (graph , GRAPH_PADDING );
907936}
908937
909- int graph_next_line (struct git_graph * graph , struct strbuf * sb )
938+ static int graph_next_line (struct git_graph * graph , struct strbuf * sb )
910939{
911940 switch (graph -> state ) {
912941 case GRAPH_PADDING :
@@ -933,7 +962,7 @@ int graph_next_line(struct git_graph *graph, struct strbuf *sb)
933962 return 0 ;
934963}
935964
936- void graph_padding_line (struct git_graph * graph , struct strbuf * sb )
965+ static void graph_padding_line (struct git_graph * graph , struct strbuf * sb )
937966{
938967 int i , j ;
939968
@@ -1055,7 +1084,7 @@ int graph_show_remainder(struct git_graph *graph)
10551084}
10561085
10571086
1058- void graph_show_strbuf (struct git_graph * graph , struct strbuf const * sb )
1087+ static void graph_show_strbuf (struct git_graph * graph , struct strbuf const * sb )
10591088{
10601089 char * p ;
10611090
0 commit comments