Skip to content

Commit 064bfbd

Browse files
Nanako Shiraishispearce
authored andcommitted
graph.c: make many functions static
These function are not used anywhere. Also removes graph_release() that is never called. Signed-off-by: Nanako Shiraishi <nanako3@lavabit.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
1 parent 697d7f5 commit 064bfbd

File tree

2 files changed

+43
-54
lines changed

2 files changed

+43
-54
lines changed

graph.c

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,43 @@
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-
191220
static 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

graph.h

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ struct git_graph;
1010
*/
1111
struct git_graph *graph_init(struct rev_info *opt);
1212

13-
/*
14-
* Destroy a struct git_graph and free associated memory.
15-
*/
16-
void graph_release(struct git_graph *graph);
17-
1813
/*
1914
* Update a git_graph with a new commit.
2015
* This will cause the graph to begin outputting lines for the new commit
@@ -26,26 +21,6 @@ void graph_release(struct git_graph *graph);
2621
*/
2722
void graph_update(struct git_graph *graph, struct commit *commit);
2823

29-
/*
30-
* Output the next line for a graph.
31-
* This formats the next graph line into the specified strbuf. It is not
32-
* terminated with a newline.
33-
*
34-
* Returns 1 if the line includes the current commit, and 0 otherwise.
35-
* graph_next_line() will return 1 exactly once for each time
36-
* graph_update() is called.
37-
*/
38-
int graph_next_line(struct git_graph *graph, struct strbuf *sb);
39-
40-
/*
41-
* Output a padding line in the graph.
42-
* This is similar to graph_next_line(). However, it is guaranteed to
43-
* never print the current commit line. Instead, if the commit line is
44-
* next, it will simply output a line of vertical padding, extending the
45-
* branch lines downwards, but leaving them otherwise unchanged.
46-
*/
47-
void graph_padding_line(struct git_graph *graph, struct strbuf *sb);
48-
4924
/*
5025
* Determine if a graph has finished outputting lines for the current
5126
* commit.
@@ -89,21 +64,6 @@ void graph_show_padding(struct git_graph *graph);
8964
*/
9065
int graph_show_remainder(struct git_graph *graph);
9166

92-
/*
93-
* Print a strbuf to stdout. If the graph is non-NULL, all lines but the
94-
* first will be prefixed with the graph output.
95-
*
96-
* If the strbuf ends with a newline, the output will end after this
97-
* newline. A new graph line will not be printed after the final newline.
98-
* If the strbuf is empty, no output will be printed.
99-
*
100-
* Since the first line will not include the graph ouput, the caller is
101-
* responsible for printing this line's graph (perhaps via
102-
* graph_show_commit() or graph_show_oneline()) before calling
103-
* graph_show_strbuf().
104-
*/
105-
void graph_show_strbuf(struct git_graph *graph, struct strbuf const *sb);
106-
10767
/*
10868
* Print a commit message strbuf and the remainder of the graph to stdout.
10969
*

0 commit comments

Comments
 (0)