| 666 | } |
| 667 | |
| 668 | static int refcol_width(const struct ref *ref_map, int compact_format) |
| 669 | { |
| 670 | const struct ref *ref; |
| 671 | int max, width = 10; |
| 672 | |
| 673 | max = term_columns(); |
| 674 | if (compact_format) |
| 675 | max = max * 2 / 3; |
| 676 | |
| 677 | for (ref = ref_map; ref; ref = ref->next) { |
| 678 | int rlen, llen = 0, len; |
| 679 | |
| 680 | if (ref->status == REF_STATUS_REJECT_SHALLOW || |
| 681 | !ref->peer_ref || |
| 682 | !strcmp(ref->name, "HEAD")) |
| 683 | continue; |
| 684 | |
| 685 | /* uptodate lines are only shown on high verbosity level */ |
| 686 | if (verbosity <= 0 && oideq(&ref->peer_ref->old_oid, &ref->old_oid)) |
| 687 | continue; |
| 688 | |
| 689 | rlen = utf8_strwidth(prettify_refname(ref->name)); |
| 690 | if (!compact_format) |
| 691 | llen = utf8_strwidth(prettify_refname(ref->peer_ref->name)); |
| 692 | |
| 693 | /* |
| 694 | * rough estimation to see if the output line is too long and |
| 695 | * should not be counted (we can't do precise calculation |
| 696 | * anyway because we don't know if the error explanation part |
| 697 | * will be printed in update_local_ref) |
| 698 | */ |
| 699 | len = 21 /* flag and summary */ + rlen + 4 /* -> */ + llen; |
| 700 | if (len >= max) |
| 701 | continue; |
| 702 | |
| 703 | if (width < rlen) |
| 704 | width = rlen; |
| 705 | } |
| 706 | |
| 707 | return width; |
| 708 | } |
| 709 | |
| 710 | static void display_state_init(struct display_state *display_state, struct ref *ref_map, |
| 711 | const char *raw_url, enum display_format format) |
no test coverage detected