From: Nguyễn Thái Ngọc Duy Date: Sun, 07 Mar 2010 12:09:43 GMT Subject: [PATCH 10/12] ls-files: support column output with --columns Message-ID: <1267963785-473-11-git-send-email-pclouds@gmail.com> In-Reply-To: <1267963785-473-1-git-send-email-pclouds@gmail.com> Signed-off-by: Nguyễn Thái Ngọc Duy --- builtin/ls-files.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/builtin/ls-files.c b/builtin/ls-files.c index b065061..10cb057 100644 --- a/builtin/ls-files.c +++ b/builtin/ls-files.c @@ -13,6 +13,7 @@ #include "parse-options.h" #include "resolve-undo.h" #include "string-list.h" +#include "column.h" static int abbrev; static int show_deleted; @@ -33,6 +34,7 @@ static int error_unmatch; static char *ps_matched; static const char *with_tree; static int exc_given; +static int show_colums = 0; static const char *tag_cached = ""; static const char *tag_unmerged = ""; @@ -514,6 +516,7 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix) "if any is not in the index, treat this as an error"), OPT_STRING(0, "with-tree", &with_tree, "tree-ish", "pretend that paths removed since are still present"), + OPT_BOOLEAN(0, "columns", &show_colums, "show files in columns"), OPT__ABBREV(&abbrev), OPT_END() }; @@ -589,6 +592,10 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix) die("ls-files --with-tree is incompatible with -s or -u"); overlay_tree_on_cache(with_tree, prefix); } + + if (show_colums) + start_columnizer(NULL); + show_files(&dir, prefix); if (show_resolve_undo) show_ru_info(prefix); @@ -602,5 +609,8 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix) return bad ? 1 : 0; } + if (show_colums) + stop_columnizer(); + return 0; } -- 1.7.0.1.370.gd3c5