| 999 | }; |
| 1000 | |
| 1001 | static void show_worktree(struct worktree *wt, struct worktree_display *display, |
| 1002 | int path_maxwidth, int abbrev_len) |
| 1003 | { |
| 1004 | struct strbuf sb = STRBUF_INIT; |
| 1005 | const char *reason; |
| 1006 | |
| 1007 | strbuf_addf(&sb, "%s%*s", display->path, 1 + path_maxwidth - display->width, ""); |
| 1008 | if (wt->is_bare) |
| 1009 | strbuf_addstr(&sb, "(bare)"); |
| 1010 | else { |
| 1011 | strbuf_addf(&sb, "%-*s ", abbrev_len, |
| 1012 | repo_find_unique_abbrev(the_repository, &wt->head_oid, DEFAULT_ABBREV)); |
| 1013 | if (wt->is_detached) |
| 1014 | strbuf_addstr(&sb, "(detached HEAD)"); |
| 1015 | else if (wt->head_ref) { |
| 1016 | char *ref = refs_shorten_unambiguous_ref(get_main_ref_store(the_repository), |
| 1017 | wt->head_ref, |
| 1018 | 0); |
| 1019 | strbuf_addf(&sb, "[%s]", ref); |
| 1020 | free(ref); |
| 1021 | } else |
| 1022 | strbuf_addstr(&sb, "(error)"); |
| 1023 | } |
| 1024 | |
| 1025 | reason = worktree_lock_reason(wt); |
| 1026 | if (verbose && reason && *reason) |
| 1027 | strbuf_addf(&sb, "\n\tlocked: %s", reason); |
| 1028 | else if (reason) |
| 1029 | strbuf_addstr(&sb, " locked"); |
| 1030 | |
| 1031 | reason = worktree_prune_reason(wt, expire); |
| 1032 | if (verbose && reason) |
| 1033 | strbuf_addf(&sb, "\n\tprunable: %s", reason); |
| 1034 | else if (reason) |
| 1035 | strbuf_addstr(&sb, " prunable"); |
| 1036 | |
| 1037 | printf("%s\n", sb.buf); |
| 1038 | strbuf_release(&sb); |
| 1039 | } |
| 1040 | |
| 1041 | static void measure_widths(struct worktree **wt, int *abbrev, |
| 1042 | struct worktree_display **d, int *maxwidth) |
no test coverage detected