Merge branch 'nd/columns'
authorJunio C Hamano <gitster@pobox.com>
Thu, 3 May 2012 22:13:31 +0000 (15:13 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 3 May 2012 22:13:31 +0000 (15:13 -0700)
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

14 files changed:
1  2 
.gitignore
Documentation/config.txt
Documentation/git-branch.txt
Documentation/git-status.txt
Makefile
builtin/branch.c
builtin/commit.c
builtin/help.c
command-list.txt
git.c
help.c
help.h
parse-options.h
t/t3200-branch.sh

diff --cc .gitignore
Simple merge
Simple merge
Simple merge
Simple merge
diff --cc Makefile
Simple merge
index f12b626a0ece679cd18a77345c3591b15d5f6cbc,9634c71ea20777964c0aa86416d4849103be793d..d51648fee4e73ef7fb72f32c722b79a913d6b275
@@@ -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;
Simple merge
diff --cc builtin/help.c
index e63668ade4dd0721c27ca5045bc8a524a147f9c1,c64f1522d839446b48154f15e189b831b047cab7..43d3c84449a57ec7028acb663d4ab4bea134c97e
@@@ -424,9 -428,10 +428,10 @@@ int cmd_help(int argc, const char **arg
        parsed_help_format = help_format;
  
        if (show_all) {
 -              printf("usage: %s\n\n", git_usage_string);
 -              list_commands("git commands", colopts, &main_cmds, &other_cmds);
 -              printf("%s\n", git_more_info_string);
+               git_config(git_help_config, NULL);
-               list_commands(&main_cmds, &other_cmds);
 +              printf(_("usage: %s%s"), _(git_usage_string), "\n\n");
++              list_commands(colopts, &main_cmds, &other_cmds);
 +              printf("%s\n", _(git_more_info_string));
                return 0;
        }
  
Simple merge
diff --cc git.c
Simple merge
diff --cc help.c
index a39b7bf8971e3ea54f0e0c0f675b3613b156eecd,a815ae62a68f55bcee4b0584f1423063450c4d8c..69d483d8d3b7e109345b1e8124df6b023ed312fb
--- 1/help.c
--- 2/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 dc406c8c50ad2c851b76d446e829550c6c444631,854d2d43d77f089767b828de48085c1490ecfd7f..0ae5a124a3af9912d551caed909aac77acc59b0b
--- 1/help.h
--- 2/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 */
diff --cc parse-options.h
Simple merge
Simple merge