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

Function measure_widths

builtin/worktree.c:1041–1062  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1039}
1040
1041static 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
1064static int pathcmp(const void *a_, const void *b_)
1065{

Callers 1

listFunction · 0.85

Calls 4

quote_pathFunction · 0.85
utf8_strwidthFunction · 0.85
strbuf_detachFunction · 0.85
repo_find_unique_abbrevFunction · 0.85

Tested by

no test coverage detected