| 1039 | } |
| 1040 | |
| 1041 | static void measure_widths(struct worktree **wt, int *abbrev, |
| 1042 | struct worktree_display **d, int *maxwidth) |
| 1043 | { |
| 1044 | int i, display_alloc = 0; |
| 1045 | struct worktree_display *display = NULL; |
| 1046 | struct strbuf buf = STRBUF_INIT; |
| 1047 | |
| 1048 | for (i = 0; wt[i]; i++) { |
| 1049 | int sha1_len; |
| 1050 | ALLOC_GROW(display, i + 1, display_alloc); |
| 1051 | quote_path(wt[i]->path, NULL, &buf, 0); |
| 1052 | display[i].width = utf8_strwidth(buf.buf); |
| 1053 | display[i].path = strbuf_detach(&buf, NULL); |
| 1054 | |
| 1055 | if (display[i].width > *maxwidth) |
| 1056 | *maxwidth = display[i].width; |
| 1057 | sha1_len = strlen(repo_find_unique_abbrev(the_repository, &wt[i]->head_oid, *abbrev)); |
| 1058 | if (sha1_len > *abbrev) |
| 1059 | *abbrev = sha1_len; |
| 1060 | } |
| 1061 | *d = display; |
| 1062 | } |
| 1063 | |
| 1064 | static int pathcmp(const void *a_, const void *b_) |
| 1065 | { |
no test coverage detected