mirror of
https://github.com/git-for-windows/git.git
synced 2026-04-29 04:28:53 -05:00
Teach status to show ignored directories with all untracked files
The git status command exposes the option to report ignored and untracked files. When reporting untracked files, it can report untracked files (--untracked=all), but this results in all ignored files being reported as well. This teaches Git to optionally show all untracked files, but not show individual ignored files contained in directories that match an ignore rule. Motivation: Our application (Visual Studio) needs all untracked files listed individually, but does not need all ignored files listed individually. Reporting all ignored files can affect the time it takes for status to run. For a representative repository, here are some measurements showing a large perf improvement for this scenario: | Command | Reported ignored entries | Time (s) | | ------- | ------------------------ | -------- | | 1 | 0 | 1.3 | | 2 | 1024 | 4.2 | | 3 | 174904 | 7.5 | | 4 | 1046 | 1.6 | Commands: 1) status 2) status --ignored 3) status --ignored --untracked-files=all 4) status --ignored --untracked-files=all --show-ignored-directory This changes exposes a --show-ignored-directory flag to the git status command. This flag is utilized when running git status with the --ignored and --untracked-files options to not list ignored individual ignored files contained in directories that match an ignore pattern. Part of the perf improvement comes from the tweak to read_directory_recursive to stop scanning the file system after it encounters the first file. When a directory is ignored, all it needs to determine is if the directory is empty or not. The logic currently keeps scanning the file system until it finds an untracked file. However, as the directory is ignored, all the contained contents are also marked excluded. For ignored directories that contain a large number of files, this can take some time. Signed-off-by: Jameson Miller <jamill@microsoft.com>
This commit is contained in:
committed by
Johannes Schindelin
parent
327460ff46
commit
5366da4376
@@ -1334,6 +1334,7 @@ static int git_status_config(const char *k, const char *v, void *cb)
|
||||
int cmd_status(int argc, const char **argv, const char *prefix)
|
||||
{
|
||||
static int no_lock_index = 0;
|
||||
static int show_ignored_directory = 0;
|
||||
static struct wt_status s;
|
||||
int fd;
|
||||
struct object_id oid;
|
||||
@@ -1365,6 +1366,8 @@ int cmd_status(int argc, const char **argv, const char *prefix)
|
||||
OPT_COLUMN(0, "column", &s.colopts, N_("list untracked files in columns")),
|
||||
OPT_BOOL(0, "no-lock-index", &no_lock_index,
|
||||
N_("do not lock the index")),
|
||||
OPT_BOOL(0, "show-ignored-directory", &show_ignored_directory,
|
||||
N_("Only show directories that match an ignore pattern name.")),
|
||||
OPT_END(),
|
||||
};
|
||||
|
||||
@@ -1397,6 +1400,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
|
||||
s.ignore_submodule_arg = ignore_submodule_arg;
|
||||
s.status_format = status_format;
|
||||
s.verbose = verbose;
|
||||
s.show_ignored_directory = show_ignored_directory;
|
||||
|
||||
wt_status_collect(&s);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user