| 899 | } |
| 900 | |
| 901 | static void graph_output_pre_commit_line(struct git_graph *graph, |
| 902 | struct graph_line *line) |
| 903 | { |
| 904 | int i, seen_this; |
| 905 | |
| 906 | /* |
| 907 | * This function formats a row that increases the space around a commit |
| 908 | * with multiple parents, to make room for it. It should only be |
| 909 | * called when there are 3 or more parents. |
| 910 | * |
| 911 | * We need 2 extra rows for every parent over 2. |
| 912 | */ |
| 913 | assert(graph->num_parents >= 3); |
| 914 | |
| 915 | /* |
| 916 | * graph->expansion_row tracks the current expansion row we are on. |
| 917 | * It should be in the range [0, num_expansion_rows - 1] |
| 918 | */ |
| 919 | assert(0 <= graph->expansion_row && |
| 920 | graph->expansion_row < graph_num_expansion_rows(graph)); |
| 921 | |
| 922 | /* |
| 923 | * Output the row |
| 924 | */ |
| 925 | seen_this = 0; |
| 926 | for (i = 0; i < graph->num_columns; i++) { |
| 927 | struct column *col = &graph->columns[i]; |
| 928 | if (col->commit == graph->commit) { |
| 929 | seen_this = 1; |
| 930 | graph_line_write_column(line, col, '|'); |
| 931 | graph_line_addchars(line, ' ', graph->expansion_row); |
| 932 | } else if (seen_this && graph_needs_truncation(graph, i)) { |
| 933 | graph_line_addstr(line, "~ "); |
| 934 | break; |
| 935 | } else if (seen_this && (graph->expansion_row == 0)) { |
| 936 | /* |
| 937 | * This is the first line of the pre-commit output. |
| 938 | * If the previous commit was a merge commit and |
| 939 | * ended in the GRAPH_POST_MERGE state, all branch |
| 940 | * lines after graph->prev_commit_index were |
| 941 | * printed as "\" on the previous line. Continue |
| 942 | * to print them as "\" on this line. Otherwise, |
| 943 | * print the branch lines as "|". |
| 944 | */ |
| 945 | if (graph->prev_state == GRAPH_POST_MERGE && |
| 946 | graph->prev_commit_index < i) |
| 947 | graph_line_write_column(line, col, '\\'); |
| 948 | else |
| 949 | graph_line_write_column(line, col, '|'); |
| 950 | } else if (seen_this && (graph->expansion_row > 0)) { |
| 951 | graph_line_write_column(line, col, '\\'); |
| 952 | } else { |
| 953 | graph_line_write_column(line, col, '|'); |
| 954 | } |
| 955 | graph_line_addch(line, ' '); |
| 956 | } |
| 957 | |
| 958 | /* |
no test coverage detected