diff options
author | Junio C Hamano <gitster@pobox.com> | 2012-05-03 15:13:31 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2012-05-03 15:13:31 -0700 |
commit | f4ed0af6e2762bc43de474d1fcaa2863b00268eb (patch) | |
tree | 0553a911a76184db89924518e79b978b65dccc23 /wt-status.c | |
parent | 9a7b0bca366d8d9b3b26f1bb1a75885780c0f0e4 (diff) | |
parent | d96e3c150f2b4508f2e7d23ce9183d5b807c2155 (diff) | |
download | git-f4ed0af6e2762bc43de474d1fcaa2863b00268eb.tar.gz git-f4ed0af6e2762bc43de474d1fcaa2863b00268eb.tar.xz |
Merge branch 'nd/columns'
A couple of commands learn --column option to produce columnar output.
By Nguyễn Thái Ngọc Duy (9) and Zbigniew Jędrzejewski-Szmek (1)
* nd/columns:
tag: add --column
column: support piping stdout to external git-column process
status: add --column
branch: add --column
help: reuse print_columns() for help -a
column: add dense layout support
t9002: work around shells that are unable to set COLUMNS to 1
column: add columnar layout
Stop starting pager recursively
Add column layout skeleton and git-column
Diffstat (limited to 'wt-status.c')
-rw-r--r-- | wt-status.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/wt-status.c b/wt-status.c index 9ffc535f1..eeef17e7b 100644 --- a/wt-status.c +++ b/wt-status.c @@ -11,6 +11,7 @@ #include "remote.h" #include "refs.h" #include "submodule.h" +#include "column.h" static char default_wt_status_colors[][COLOR_MAXLEN] = { GIT_COLOR_NORMAL, /* WT_STATUS_HEADER */ @@ -641,6 +642,8 @@ static void wt_status_print_other(struct wt_status *s, { int i; struct strbuf buf = STRBUF_INIT; + static struct string_list output = STRING_LIST_INIT_DUP; + struct column_options copts; if (!l->nr) return; @@ -649,12 +652,33 @@ static void wt_status_print_other(struct wt_status *s, for (i = 0; i < l->nr; i++) { struct string_list_item *it; + const char *path; it = &(l->items[i]); + path = quote_path(it->string, strlen(it->string), + &buf, s->prefix); + if (column_active(s->colopts)) { + string_list_append(&output, path); + continue; + } status_printf(s, color(WT_STATUS_HEADER, s), "\t"); status_printf_more(s, color(WT_STATUS_UNTRACKED, s), - "%s\n", quote_path(it->string, strlen(it->string), - &buf, s->prefix)); + "%s\n", path); } + + strbuf_release(&buf); + if (!column_active(s->colopts)) + return; + + strbuf_addf(&buf, "%s#\t%s", + color(WT_STATUS_HEADER, s), + color(WT_STATUS_UNTRACKED, s)); + memset(&copts, 0, sizeof(copts)); + copts.padding = 1; + copts.indent = buf.buf; + if (want_color(s->use_color)) + copts.nl = GIT_COLOR_RESET "\n"; + print_columns(&output, s->colopts, &copts); + string_list_clear(&output, 0); strbuf_release(&buf); } |