732
{
733
int i;
734
735
- /*
736
- * We could conceivable be called with a NULL commit
737
- * if our caller has a bug, and invokes graph_next_line()
738
- * immediately after graph_init(), without first calling
739
- * graph_update(). Return without outputting anything in this
740
- * case.
741
- */
742
- if (!graph->commit)
743
- return;
744
-
735
/*
736
* Output a padding row, that leaves all branch lines unchanged
737
*/
739
graph_line_write_column(line, &graph->new_columns[i], '|');
740
graph_line_addch(line, ' ');
741
}
752
-
753
- graph_pad_horizontally(graph, line);
742
}
743
744
755
* of the graph is missing.
756
*/
757
graph_line_addstr(line, "...");
770
- graph_pad_horizontally(graph, line);
758
759
if (graph->num_parents >= 3 &&
760
graph->commit_index < (graph->num_columns - 1))
819
graph_line_addch(line, ' ');
820
}
821
835
- graph_pad_horizontally(graph, line);
836
-
822
/*
823
* Increment graph->expansion_row,
824
* and move to state GRAPH_COMMIT if necessary
952
graph_line_addch(line, ' ');
953
}
954
970
- graph_pad_horizontally(graph, line);
971
-
955
/*
956
* Update graph->state
957
*/
1026
}
1027
}
1028
1046
- graph_pad_horizontally(graph, line);
1047
-
1029
/*
1030
* Update graph->state
1031
*/
1167
}
1168
}
1169
1189
- graph_pad_horizontally(graph, line);
1190
-
1170
/*
1171
* Swap mapping and new_mapping
1172
*/
1183
1184
int graph_next_line(struct git_graph *graph, struct strbuf *sb)
1185
{
1186
+ int shown_commit_line = 0;
1187
struct graph_line line = { .buf = sb, .width = 0 };
1188
1189
+ /*
1190
+ * We could conceivable be called with a NULL commit
1191
+ * if our caller has a bug, and invokes graph_next_line()
1192
+ * immediately after graph_init(), without first calling
1193
+ * graph_update(). Return without outputting anything in this
1194
+ * case.
1195
+ */
1196
+ if (!graph->commit)
1197
+ return -1;
1198
+
1199
switch (graph->state) {
1200
case GRAPH_PADDING:
1201
graph_output_padding_line(graph, &line);
1212
- return 0;
1202
+ break;
1203
case GRAPH_SKIP:
1204
graph_output_skip_line(graph, &line);
1215
- return 0;
1205
+ break;
1206
case GRAPH_PRE_COMMIT:
1207
graph_output_pre_commit_line(graph, &line);
1218
- return 0;
1208
+ break;
1209
case GRAPH_COMMIT:
1210
graph_output_commit_line(graph, &line);
1221
- return 1;
1211
+ shown_commit_line = 1;
1212
+ break;
1213
case GRAPH_POST_MERGE:
1214
graph_output_post_merge_line(graph, &line);
1224
- return 0;
1215
+ break;
1216
case GRAPH_COLLAPSING:
1217
graph_output_collapsing_line(graph, &line);
1227
- return 0;
1218
+ break;
1219
}
1220
1230
- assert(0);
1231
- return 0;
1221
+ graph_pad_horizontally(graph, &line);
1222
+ return shown_commit_line;
1223
}
1224
1225
static void graph_padding_line(struct git_graph *graph, struct strbuf *sb)