From: Junio C Hamano Date: Thu, 3 May 2012 22:13:31 +0000 (-0700) Subject: Merge branch 'nd/columns' X-Git-Tag: v1.7.11-rc0~60 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/f4ed0af6e2762bc43de474d1fcaa2863b00268eb 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 --- f4ed0af6e2762bc43de474d1fcaa2863b00268eb diff --cc builtin/branch.c index f12b626a0e,9634c71ea2..d51648fee4 --- a/builtin/branch.c +++ b/builtin/branch.c @@@ -774,12 -774,22 +788,22 @@@ int cmd_branch(int argc, const char **a if (abbrev == -1) abbrev = DEFAULT_ABBREV; + finalize_colopts(&colopts, -1); + if (verbose) { + if (explicitly_enable_column(colopts)) + die(_("--column and --verbose are incompatible")); + colopts = 0; + } if (delete) - return delete_branches(argc, argv, delete > 1, kinds); + return delete_branches(argc, argv, delete > 1, kinds, quiet); - else if (list) - return print_ref_list(kinds, detached, verbose, abbrev, - with_commit, argv); + else if (list) { + int ret = print_ref_list(kinds, detached, verbose, abbrev, + with_commit, argv); + print_columns(&output, colopts, NULL); + string_list_clear(&output, 0); + return ret; + } else if (edit_description) { const char *branch_name; struct strbuf branch_ref = STRBUF_INIT; diff --cc builtin/help.c index e63668ade4,c64f1522d8..43d3c84449 --- a/builtin/help.c +++ b/builtin/help.c @@@ -424,9 -428,10 +428,10 @@@ int cmd_help(int argc, const char **arg parsed_help_format = help_format; if (show_all) { + git_config(git_help_config, NULL); - printf("usage: %s\n\n", git_usage_string); - list_commands("git commands", colopts, &main_cmds, &other_cmds); - printf("%s\n", git_more_info_string); + printf(_("usage: %s%s"), _(git_usage_string), "\n\n"); - list_commands(&main_cmds, &other_cmds); ++ list_commands(colopts, &main_cmds, &other_cmds); + printf("%s\n", _(git_more_info_string)); return 0; } diff --cc help.c index a39b7bf897,a815ae62a6..69d483d8d3 --- a/help.c +++ b/help.c @@@ -203,29 -199,25 +199,21 @@@ void load_command_list(const char *pref exclude_cmds(other_cmds, main_cmds); } - void list_commands(struct cmdnames *main_cmds, struct cmdnames *other_cmds) -void list_commands(const char *title, unsigned int colopts, ++void list_commands(unsigned int colopts, + struct cmdnames *main_cmds, struct cmdnames *other_cmds) { - int i, longest = 0; - - for (i = 0; i < main_cmds->cnt; i++) - if (longest < main_cmds->names[i]->len) - longest = main_cmds->names[i]->len; - for (i = 0; i < other_cmds->cnt; i++) - if (longest < other_cmds->names[i]->len) - longest = other_cmds->names[i]->len; - if (main_cmds->cnt) { const char *exec_path = git_exec_path(); - printf("available %s in '%s'\n", title, exec_path); - printf("----------------"); - mput_char('-', strlen(title) + strlen(exec_path)); + printf_ln(_("available git commands in '%s'"), exec_path); putchar('\n'); - pretty_print_string_list(main_cmds, longest); + pretty_print_string_list(main_cmds, colopts); putchar('\n'); } if (other_cmds->cnt) { - printf("%s available from elsewhere on your $PATH\n", title); - printf("---------------------------------------"); - mput_char('-', strlen(title)); + printf_ln(_("git commands available from elsewhere on your $PATH")); putchar('\n'); - pretty_print_string_list(other_cmds, longest); + pretty_print_string_list(other_cmds, colopts); putchar('\n'); } } diff --cc help.h index dc406c8c50,854d2d43d7..0ae5a124a3 --- a/help.h +++ b/help.h @@@ -25,7 -25,8 +25,6 @@@ extern void add_cmdname(struct cmdname /* Here we require that excludes is a sorted list. */ extern void exclude_cmds(struct cmdnames *cmds, struct cmdnames *excludes); extern int is_in_cmdlist(struct cmdnames *cmds, const char *name); - extern void list_commands(struct cmdnames *main_cmds, -extern void list_commands(const char *title, unsigned int colopts, - struct cmdnames *main_cmds, -- struct cmdnames *other_cmds); ++extern void list_commands(unsigned int colopts, struct cmdnames *main_cmds, struct cmdnames *other_cmds); #endif /* HELP_H */