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

4 messages from 2007-08-23 to 2007-08-24. Participants: Väinö Järvelä, Matthieu Moy.
Thread: https://gitlist.dev/t/9625

## Väinö Järvelä, 2007-08-23 19:58

Subject: [PATCH 1/2] Add "--only-untracked" flag to status commands.
Message-ID: <11878991123605-git-send-email-v@pp.inet.fi>
URL: https://gitlist.dev/e/11878991123605-git-send-email-v%40pp.inet.fi

```
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ä <v@pp.inet.fi>
---
 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

```

## Väinö Järvelä, 2007-08-23 19:58

Subject: [PATCH 2/2] Documented "--only-untracked" flag.
Message-ID: <11878991173082-git-send-email-v@pp.inet.fi>
URL: https://gitlist.dev/e/11878991173082-git-send-email-v%40pp.inet.fi
In-Reply-To: <11878991123605-git-send-email-v@pp.inet.fi>

```
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ä <v@pp.inet.fi>
---
 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

```

## Matthieu Moy, 2007-08-23 20:50

Subject: Re: [PATCH 1/2] Add "--only-untracked" flag to status commands.
Message-ID: <vpqabsikmbg.fsf@bauges.imag.fr>
URL: https://gitlist.dev/e/vpqabsikmbg.fsf%40bauges.imag.fr
In-Reply-To: <11878991123605-git-send-email-v@pp.inet.fi>

```
Väinö Järvelä <v@pp.inet.fi> writes:

> Subject: Re: [PATCH 1/2] Add "--only-untracked" flag to status commands.
                                       ^^

I suppose you meant --only-tracked.

>  static const char runstatus_usage[] =
> -"git-runstatus [--color|--nocolor] [--amend] [--verbose] [--untracked]";
> +"git-runstatus [--color|--nocolor] [--amend] [--verbose]
> [--untracked]" "[--only-tracked]";
               ^^^

The compiler will concatenate the strings, but won't add a space. That
results in "... [--untracked][--only-tracked]".

Otherwise, the patch sounds fine to me. Not /terribly/ usefull, but
why not.

-- 
Matthieu

```

## Väinö Järvelä, 2007-08-24 06:28

Subject: Re: [PATCH 1/2] Add "--only-untracked" flag to status commands.
Message-ID: <1C01FFED-1C80-4C1F-A73D-2529B5B81F7E@pp.inet.fi>
URL: https://gitlist.dev/e/1C01FFED-1C80-4C1F-A73D-2529B5B81F7E%40pp.inet.fi
In-Reply-To: <vpqabsikmbg.fsf@bauges.imag.fr>

```
On Aug 23, 2007, at 23:50, Matthieu Moy wrote:

> Väinö Järvelä <v@pp.inet.fi> writes:
>
>> Subject: Re: [PATCH 1/2] Add "--only-untracked" flag to status  
>> commands.
>                                        ^^
>
> I suppose you meant --only-tracked.

Yes, a stupid typo. It should be --only-tracked.

>>  static const char runstatus_usage[] =
>> -"git-runstatus [--color|--nocolor] [--amend] [--verbose] [-- 
>> untracked]";
>> +"git-runstatus [--color|--nocolor] [--amend] [--verbose]
>> [--untracked]" "[--only-tracked]";
>                ^^^
>
> The compiler will concatenate the strings, but won't add a space. That
> results in "... [--untracked][--only-tracked]".

Should have checked it more properly, sorry about that.

>
> Otherwise, the patch sounds fine to me. Not /terribly/ usefull, but
> why not.

This is something that has come up many times on our project, there  
might be a lot of temporary files that are used inside the project  
tree, to test the code, and the user just wants to see the  
modifications to tracked files without using a pager. One could use  
gitignore, but in our case, it would be hard to create a gitignore  
which would ignore all of the test files, and none of the actual  
project files, so it's quite convenient to use --only-tracked.

A better behavior might be to test outside of the project tree.

>
> -- 
> Matthieu

--
Väinö
```
