[PATCH 1/2] Add "--only-untracked" flag to status commands.

Subsystems: the rest

DORMANTno replies

2 messages, 1 author, 2016-06-15 · open the first message on its own page

[PATCH 1/2] Add "--only-untracked" flag to status commands.

From: Väinö Järvelä <hidden>
Date: 2016-06-15 22:43:30

With this flag, the user can choose to filter untracked files from the
status output. This can be used to either speed up the status output, as
the untracked files are not fetched at all, or to just cleanup the
output without using gitignore.

Signed-off-by: Väinö Järvelä <redacted>
---
 builtin-runstatus.c |    4 +++-
 git-commit.sh       |   11 +++++++++--
 wt-status.c         |    8 +++++++-
 wt-status.h         |    1 +
 4 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/builtin-runstatus.c b/builtin-runstatus.c
index 2db25c8..2121762 100644
--- a/builtin-runstatus.c
+++ b/builtin-runstatus.c
@@ -5,7 +5,7 @@
 extern int wt_status_use_color;
 
 static const char runstatus_usage[] =
-"git-runstatus [--color|--nocolor] [--amend] [--verbose] [--untracked]";
+"git-runstatus [--color|--nocolor] [--amend] [--verbose] [--untracked]" "[--only-tracked]";
 
 int cmd_runstatus(int argc, const char **argv, const char *prefix)
 {
@@ -28,6 +28,8 @@ int cmd_runstatus(int argc, const char **argv, const char *prefix)
 			s.verbose = 1;
 		else if (!strcmp(argv[i], "--untracked"))
 			s.untracked = 1;
+		else if (!strcmp(argv[i], "--only-tracked"))
+			s.only_tracked = 1;
 		else
 			usage(runstatus_usage);
 	}
diff --git a/git-commit.sh b/git-commit.sh
index d7e7028..0ef50d9 100755
--- a/git-commit.sh
+++ b/git-commit.sh
@@ -3,7 +3,7 @@
 # Copyright (c) 2005 Linus Torvalds
 # Copyright (c) 2006 Junio C Hamano
 
-USAGE='[-a | --interactive] [-s] [-v] [--no-verify] [-m <message> | -F <logfile> | (-C|-c) <commit> | --amend] [-u] [-e] [--author <author>] [--template <file>] [[-i | -o] <path>...]'
+USAGE='[-a | --interactive] [-s] [-v] [--no-verify] [-m <message> | -F <logfile> | (-C|-c) <commit> | --amend] [-u] [-e] [--author <author>] [--template <file>] [--only-tracked] [[-i | -o] <path>...]'
 SUBDIRECTORY_OK=Yes
 . git-sh-setup
 require_work_tree
@@ -56,7 +56,8 @@ run_status () {
 	git runstatus ${color} \
 		${verbose:+--verbose} \
 		${amend:+--amend} \
-		${untracked_files:+--untracked}
+		${untracked_files:+--untracked} \
+		${only_tracked:+--only-tracked}
 }
 
 trap '
@@ -87,6 +88,7 @@ signoff=
 force_author=
 only_include_assumed=
 untracked_files=
+only_tracked=
 templatefile="`git config commit.template`"
 while case "$#" in 0) break;; esac
 do
@@ -269,6 +271,11 @@ $1"
 		untracked_files=t
 		shift
 		;;
+    --only-|--only-t|--only-tr|--only-tra|--only-trac|--only-track|\
+    --only-tracke|--only-tracked)
+        only_tracked=t
+        shift
+        ;;
 	--)
 		shift
 		break
diff --git a/wt-status.c b/wt-status.c
index 5205420..7c2c468 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -331,7 +331,13 @@ void wt_status_print(struct wt_status *s)
 	}
 
 	wt_status_print_changed(s);
-	wt_status_print_untracked(s);
+
+	if (!s->only_tracked) {
+		wt_status_print_untracked(s);
+	}
+	else {
+		printf("# Untracked files were filtered by \"--only-tracked\"\n");
+	}
 
 	if (s->verbose && !s->is_initial)
 		wt_status_print_verbose(s);
diff --git a/wt-status.h b/wt-status.h
index cfea4ae..45b7e09 100644
--- a/wt-status.h
+++ b/wt-status.h
@@ -15,6 +15,7 @@ struct wt_status {
 	int verbose;
 	int amend;
 	int untracked;
+	int only_tracked;
 	/* These are computed during processing of the individual sections */
 	int commitable;
 	int workdir_dirty;
-- 
1.5.3.rc6.17.g1911-dirty

[PATCH 2/2] Documented "--only-untracked" flag.

From: Väinö Järvelä <hidden>
Date: 2016-06-15 22:43:30

Also moved a paragraph about git-status options from description
section, to options section. Which makes it easier to quickly search for
git-status options without reading the description, even though the
description for options forwards to git-commit manual.

Signed-off-by: Väinö Järvelä <redacted>
---
 Documentation/git-runstatus.txt |    4 +++-
 Documentation/git-status.txt    |   17 ++++++++++++-----
 2 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/Documentation/git-runstatus.txt b/Documentation/git-runstatus.txt
index dee5d0d..56af1c1 100644
--- a/Documentation/git-runstatus.txt
+++ b/Documentation/git-runstatus.txt
@@ -8,7 +8,7 @@ git-runstatus - A helper for git-status and git-commit
 
 SYNOPSIS
 --------
-'git-runstatus' [--color|--nocolor] [--amend] [--verbose] [--untracked]
+'git-runstatus' [--color|--nocolor] [--amend] [--verbose] [--untracked] [--only-tracked]
 
 
 DESCRIPTION
@@ -47,6 +47,8 @@ OPTIONS
 	option only its name and a trailing slash are displayed
 	for each untracked directory.
 
+--only-tracked:
+	Hide untracked files from the output.
 
 OUTPUT
 ------
diff --git a/Documentation/git-status.txt b/Documentation/git-status.txt
index 8fd0fc6..de9f5ff 100644
--- a/Documentation/git-status.txt
+++ b/Documentation/git-status.txt
@@ -8,7 +8,7 @@ git-status - Show the working tree status
 
 SYNOPSIS
 --------
-'git-status' <options>...
+'git-status' [--only-tracked] <options>...
 
 DESCRIPTION
 -----------
@@ -23,10 +23,6 @@ If there is no path that is different between the index file and
 the current HEAD commit, the command exits with non-zero
 status.
 
-The command takes the same set of options as `git-commit`; it
-shows what would be committed if the same options are given to
-`git-commit`.
-
 If any paths have been touched in the working tree (that is,
 their modification times have changed) but their contents and
 permissions are identical to those in the index file, the command
@@ -35,6 +31,17 @@ subsequent operations such as `git-diff` if the working tree
 contains many paths that have been touched but not modified.
 
 
+OPTIONS
+-------
+--only-tracked::
+	Hide untracked files from the output.
+
+<options>::
+	The command takes the same set of options as `git-commit`; it
+	shows what would be committed if the same options are given to
+	`git-commit`.
+
+
 OUTPUT
 ------
 The output from this command is designed to be used as a commit
-- 
1.5.3.rc6.17.g1911-dirty
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help