MCPcopy Create free account
hub / github.com/git/git / shrink_columns

Function shrink_columns

column.c:75–101  ·  view source on GitHub ↗

* Shrink all columns by shortening them one row each time (and adding * more columns along the way). Hopefully the longest cell will be * moved to the next column, column is shrunk so we have more space * for new columns. The process ends when the whole thing no longer * fits in data->total_width. */

Source from the content-addressed store, hash-verified

73 * fits in data->total_width.
74 */
75static void shrink_columns(struct column_data *data)
76{
77 REALLOC_ARRAY(data->width, data->cols);
78 while (data->rows > 1) {
79 int x, total_width, cols, rows;
80 rows = data->rows;
81 cols = data->cols;
82
83 data->rows--;
84 data->cols = DIV_ROUND_UP(data->list->nr, data->rows);
85 if (data->cols != cols)
86 REALLOC_ARRAY(data->width, data->cols);
87 compute_column_width(data);
88
89 total_width = strlen(data->opts.indent);
90 for (x = 0; x < data->cols; x++) {
91 total_width += data->len[data->width[x]];
92 total_width += data->opts.padding;
93 }
94 if (total_width > data->opts.width) {
95 data->rows = rows;
96 data->cols = cols;
97 break;
98 }
99 }
100 compute_column_width(data);
101}
102
103/* Display without layout when not enabled */
104static void display_plain(const struct string_list *list,

Callers 1

display_tableFunction · 0.85

Calls 1

compute_column_widthFunction · 0.85

Tested by

no test coverage detected