static void print_ref_item(struct ref_item *item, int maxwidth, int verbose, int abbrev, int current) { char c; int color; struct commit *commit = item->commit; if (!matches_merge_filter(commit)) return; switch (item->kind) { case REF_LOCAL_BRANCH: color = COLOR_BRANCH_LOCAL; break; case REF_REMOTE_BRANCH: color = COLOR_BRANCH_REMOTE; break; default: color = COLOR_BRANCH_PLAIN; break; } c = ' '; if (current) { c = '*'; color = COLOR_BRANCH_CURRENT; } if (verbose) { struct strbuf subject = STRBUF_INIT, stat = STRBUF_INIT; const char *sub = " **** invalid ref ****"; commit = item->commit; if (commit && !parse_commit(commit)) { pretty_print_commit(CMIT_FMT_ONELINE, commit, &subject, 0, NULL, NULL, 0, 0); sub = subject.buf; } if (item->kind == REF_LOCAL_BRANCH) fill_tracking_info(&stat, item->name); printf("%c %s%-*s%s %s %s%s\n", c, branch_get_color(color), maxwidth, item->name, branch_get_color(COLOR_BRANCH_RESET), find_unique_abbrev(item->commit->object.sha1, abbrev), stat.buf, sub); strbuf_release(&stat); strbuf_release(&subject); } else { printf("%c %s%s%s\n", c, branch_get_color(color), item->name, branch_get_color(COLOR_BRANCH_RESET)); } }
static int calc_maxwidth(struct ref_list *refs) { int i, w = 0; for (i = 0; i < refs->index; i++) { if (!matches_merge_filter(refs->list[i].commit)) continue; if (refs->list[i].width > w) w = refs->list[i].width; } return w; }
static int calc_maxwidth(struct ref_list *refs) { int i, l, w = 0; for (i = 0; i < refs->index; i++) { if (!matches_merge_filter(refs->list[i].commit)) continue; l = strlen(refs->list[i].name); if (l > w) w = l; } return w; }
static void print_ref_item(struct ref_item *item, int maxwidth, int verbose, int abbrev, int current, char *prefix) { char c; int color; struct commit *commit = item->commit; struct strbuf out = STRBUF_INIT, name = STRBUF_INIT; if (!matches_merge_filter(commit)) return; switch (item->kind) { case REF_LOCAL_BRANCH: color = BRANCH_COLOR_LOCAL; break; case REF_REMOTE_BRANCH: color = BRANCH_COLOR_REMOTE; break; default: color = BRANCH_COLOR_PLAIN; break; } c = ' '; if (current) { c = '*'; color = BRANCH_COLOR_CURRENT; } strbuf_addf(&name, "%s%s", prefix, item->name); if (verbose) { int utf8_compensation = strlen(name.buf) - utf8_strwidth(name.buf); strbuf_addf(&out, "%c %s%-*s%s", c, branch_get_color(color), maxwidth + utf8_compensation, name.buf, branch_get_color(BRANCH_COLOR_RESET)); } else strbuf_addf(&out, "%c %s%s%s", c, branch_get_color(color), name.buf, branch_get_color(BRANCH_COLOR_RESET)); if (item->dest) strbuf_addf(&out, " -> %s", item->dest); else if (verbose) /* " f7c0c00 [ahead 58, behind 197] vcs-svn: drop obj_pool.h" */ add_verbose_info(&out, item, verbose, abbrev); if (column_active(colopts)) { assert(!verbose && "--column and --verbose are incompatible"); string_list_append(&output, out.buf); } else { printf("%s\n", out.buf); } strbuf_release(&name); strbuf_release(&out); }
static void print_ref_item(struct ref_item *item, int maxwidth, int verbose, int abbrev, int current, char *prefix) { char c; int color; struct commit *commit = item->commit; struct strbuf out = STRBUF_INIT, name = STRBUF_INIT; if (!matches_merge_filter(commit)) return; switch (item->kind) { case REF_LOCAL_BRANCH: color = BRANCH_COLOR_LOCAL; break; case REF_REMOTE_BRANCH: color = BRANCH_COLOR_REMOTE; break; default: color = BRANCH_COLOR_PLAIN; break; } c = ' '; if (current) { c = '*'; color = BRANCH_COLOR_CURRENT; } strbuf_addf(&name, "%s%s", prefix, item->name); if (verbose) strbuf_addf(&out, "%c %s%-*s%s", c, branch_get_color(color), maxwidth, name.buf, branch_get_color(BRANCH_COLOR_RESET)); else strbuf_addf(&out, "%c %s%s%s", c, branch_get_color(color), name.buf, branch_get_color(BRANCH_COLOR_RESET)); if (item->dest) strbuf_addf(&out, " -> %s", item->dest); else if (verbose) /* " f7c0c00 [ahead 58, behind 197] vcs-svn: drop obj_pool.h" */ add_verbose_info(&out, item, verbose, abbrev); printf("%s\n", out.buf); strbuf_release(&name); strbuf_release(&out); }