[PATCH 8/8] Add git-ls, a user friendly version of ls-files and more

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



For now it's simply a wrapper of ls-files with some default
goodies. But I want it to be the UI for ls-tree and perhaps git diff
--name-only [--cached] too.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx>
---
 builtin.h          |  1 +
 builtin/ls-files.c | 19 +++++++++++++++++++
 git.c              |  1 +
 3 files changed, 21 insertions(+)

diff --git a/builtin.h b/builtin.h
index c47c110..177aa7d 100644
--- a/builtin.h
+++ b/builtin.h
@@ -75,6 +75,7 @@ extern int cmd_index_pack(int argc, const char **argv, const char *prefix);
 extern int cmd_init_db(int argc, const char **argv, const char *prefix);
 extern int cmd_log(int argc, const char **argv, const char *prefix);
 extern int cmd_log_reflog(int argc, const char **argv, const char *prefix);
+extern int cmd_ls(int argc, const char **argv, const char *prefix);
 extern int cmd_ls_files(int argc, const char **argv, const char *prefix);
 extern int cmd_ls_tree(int argc, const char **argv, const char *prefix);
 extern int cmd_ls_remote(int argc, const char **argv, const char *prefix);
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index 2c51b0a..5354339 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -17,6 +17,7 @@
 #include "color.h"
 #include "ls_colors.h"
 #include "column.h"
+#include "argv-array.h"
 
 static int abbrev;
 static int show_deleted;
@@ -479,6 +480,7 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
 	int require_work_tree = 0, show_tag = 0, i;
 	unsigned int colopts = 0;
 	int max_depth = -1;
+	int refresh = 0;
 	const char *max_prefix;
 	struct dir_struct dir;
 	struct exclude_list *el;
@@ -539,6 +541,7 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
 		{ OPTION_INTEGER, 0, "max-depth", &max_depth, N_("depth"),
 			N_("descend at most <depth> levels"), PARSE_OPT_NONEG,
 			NULL, 1 },
+		OPT_HIDDEN_BOOL(0, "refresh-index", &refresh, N_("refresh index")),
 		OPT__ABBREV(&abbrev),
 		OPT_BOOL(0, "debug", &debug_mode, N_("show debugging data")),
 		OPT_END()
@@ -555,6 +558,8 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
 
 	if (read_cache() < 0)
 		die("index file corrupt");
+	if (refresh)
+		refresh_cache(REFRESH_QUIET);
 
 	argc = parse_options(argc, argv, prefix, builtin_ls_files_options,
 			ls_files_usage, 0);
@@ -652,3 +657,17 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
 
 	return 0;
 }
+
+int cmd_ls(int argc, const char **argv, const char *cmd_prefix)
+{
+	struct argv_array av = ARGV_ARRAY_INIT;
+	argv_array_pushl(&av, "ls-files",
+			 "--color", "--column", "--max-depth=0",
+			 "--exclude-standard", "--refresh-index",
+			 NULL);
+	argv++;
+	while (*argv)
+		argv_array_push(&av, *argv++);
+	trace_argv_printf(av.argv, "trace: built-in: git");
+	return cmd_ls_files(av.argc, av.argv, cmd_prefix);
+}
diff --git a/git.c b/git.c
index 9efd1a3..682a81e 100644
--- a/git.c
+++ b/git.c
@@ -381,6 +381,7 @@ static struct cmd_struct commands[] = {
 	{ "init", cmd_init_db },
 	{ "init-db", cmd_init_db },
 	{ "log", cmd_log, RUN_SETUP },
+	{ "ls", cmd_ls, RUN_SETUP },
 	{ "ls-files", cmd_ls_files, RUN_SETUP },
 	{ "ls-remote", cmd_ls_remote, RUN_SETUP_GENTLY },
 	{ "ls-tree", cmd_ls_tree, RUN_SETUP },
-- 
1.9.0.40.gaa8c3ea

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]