Thread (39 messages) flat view 39 messages, 2 authors, 2016-06-15
DORMANTno replies

[PATCH v7 10/9] ls-files: support --column

From: Nguyễn Thái Ngọc Duy <hidden>
Date: 2016-06-15 22:53:17
Subsystem: the rest · Maintainer: Linus Torvalds

.. because ls-files is a good show case to the next patches..

Signed-off-by: Nguyễn Thái Ngọc Duy <redacted>
---
 builtin/ls-files.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index 7cff175..e191f4f 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;
@@ -35,6 +36,7 @@ static int error_unmatch;
 static char *ps_matched;
 static const char *with_tree;
 static int exc_given;
+static unsigned int colopts;
 
 static const char *tag_cached = "";
 static const char *tag_unmerged = "";
@@ -496,6 +498,7 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
 		OPT_STRING(0, "with-tree", &with_tree, "tree-ish",
 			"pretend that paths removed since <tree-ish> are still present"),
 		OPT__ABBREV(&abbrev),
+		OPT_COLUMN(0, "column", &colopts, "list branches in columns"),
 		OPT_BOOLEAN(0, "debug", &debug_mode, "show debugging data"),
 		OPT_END()
 	};
@@ -514,6 +517,7 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
 
 	argc = parse_options(argc, argv, prefix, builtin_ls_files_options,
 			ls_files_usage, 0);
+	finalize_colopts(&colopts, -1);
 	if (show_tag || show_valid_bit) {
 		tag_cached = "H ";
 		tag_unmerged = "M ";
@@ -575,7 +579,11 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
 			die("ls-files --with-tree is incompatible with -s or -u");
 		overlay_tree_on_cache(with_tree, max_prefix);
 	}
+	if (COL_ENABLE(colopts))
+		run_column_filter(colopts, NULL);
 	show_files(&dir);
+	if (COL_ENABLE(colopts))
+		stop_column_filter();
 	if (show_resolve_undo)
 		show_ru_info();
 
-- 
1.7.8.36.g69ee2
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help